MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_ML2MueLuParameterTranslator.cpp
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#include "MueLu_ConfigDefs.hpp"
11#include "Teuchos_ParameterList.hpp"
12#include "Teuchos_TestForException.hpp"
13
15using Teuchos::ParameterList;
16
17namespace MueLu {
18
19std::string ML2MueLuParameterTranslator::GetSmootherFactory(const Teuchos::ParameterList& paramList, Teuchos::ParameterList& adaptingParamList, const std::string& pname, const std::string& value) {
20 TEUCHOS_TEST_FOR_EXCEPTION(pname != "coarse: type" && pname != "coarse: list" && pname != "smoother: type" && pname.find("smoother: list", 0) != 0,
22 "MueLu::MLParameterListInterpreter::Setup(): Only \"coarse: type\", \"smoother: type\" or \"smoother: list\" (\"coarse: list\") are "
23 "supported as ML parameters for transformation of smoother/solver parameters to MueLu");
24
25 // string stream containing the smoother/solver xml parameters
26 std::stringstream mueluss;
27
28 // Check whether we are dealing with coarse level (solver) parameters or level smoother parameters
29 std::string mode = "smoother:";
30 bool is_coarse = false;
31 if (pname.find("coarse:", 0) == 0) {
32 mode = "coarse:";
33 is_coarse = true;
34 }
35
36 // check whether pre and/or post smoothing
37 std::string PreOrPost = "both";
38 if (paramList.isParameter(mode + " pre or post"))
39 PreOrPost = paramList.get<std::string>(mode + " pre or post");
40
41 TEUCHOS_TEST_FOR_EXCEPTION(mode == "coarse:" && PreOrPost != "both", Exceptions::RuntimeError,
42 "MueLu::MLParameterListInterpreter::Setup(): The parameter \"coarse: pre or post\" is not supported by MueLu. "
43 "It does not make sense for direct solvers. For iterative solvers you obtain the same effect by increasing, "
44 "e.g., the number of sweeps for the coarse grid smoother. Please remove it from your parameters.");
45
46 // select smoother type
47 std::string valuestr = value; // temporary variable
48 std::transform(valuestr.begin(), valuestr.end(), valuestr.begin(), ::tolower);
49 if (valuestr == "jacobi" || valuestr == "gauss-seidel" || valuestr == "symmetric gauss-seidel") {
50 std::string my_name;
51 if (PreOrPost == "both")
52 my_name = "\"" + pname + "\"";
53 else
54 my_name = "\"smoother: " + PreOrPost + " type\"";
55 mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"RELAXATION\"/>" << std::endl;
56
57 } else if (valuestr == "hiptmair") {
58 std::string my_name;
59 if (PreOrPost == "both")
60 my_name = "\"" + pname + "\"";
61 else
62 my_name = "\"smoother: " + PreOrPost + " type\"";
63 mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"HIPTMAIR\"/>" << std::endl;
64
65 } else if (valuestr == "ifpack") {
66 std::string my_name = "\"" + pname + "\"";
67 if (paramList.isParameter("smoother: ifpack type")) {
68 if (paramList.get<std::string>("smoother: ifpack type") == "ILU") {
69 mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"ILU\"/>" << std::endl;
70 adaptingParamList.remove("smoother: ifpack type", false);
71 }
72 if (paramList.get<std::string>("smoother: ifpack type") == "ILUT") {
73 mueluss << "<Parameter name=" << my_name << " type\" type=\"string\" value=\"ILUT\"/>" << std::endl;
74 adaptingParamList.remove("smoother: ifpack type", false);
75 }
76 }
77
78 } else if ((valuestr == "chebyshev") || (valuestr == "mls")) {
79 std::string my_name = "\"" + pname + "\"";
80 mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"CHEBYSHEV\"/>" << std::endl;
81
82 } else if (valuestr.length() > strlen("amesos") && valuestr.substr(0, strlen("amesos")) == "amesos") { /* catch Amesos-* */
83 std::string solverType = valuestr.substr(strlen("amesos") + 1); /* ("amesos-klu" -> "klu") */
84
85 bool valid = false;
86 const int validatorSize = 5;
87 std::string validator[validatorSize] = {"superlu", "superludist", "klu", "umfpack", "mumps"};
88 for (int i = 0; i < validatorSize; i++)
89 if (validator[i] == solverType)
90 valid = true;
91 TEUCHOS_TEST_FOR_EXCEPTION(!valid, Exceptions::RuntimeError,
92 "MueLu::MLParameterListInterpreter: unknown smoother type. '" << solverType << "' not supported.");
93
94 mueluss << "<Parameter name=\"" << pname << "\" type=\"string\" value=\"" << solverType << "\"/>" << std::endl;
95 } else {
96 // TODO error message
97 std::cout << "error in " << __FILE__ << ":" << __LINE__ << " could not find valid smoother/solver: " << valuestr << std::endl;
98 }
99
100 // set smoother: pre or post parameter
101 // Note that there is no "coarse: pre or post" in MueLu!
102 if (paramList.isParameter("smoother: pre or post") && mode == "smoother:") {
103 // std::cout << "paramList" << paramList << std::endl;
104 // std::string smootherPreOrPost = paramList.get<std::string>("smoother: pre or post");
105 // std::cout << "Create pre or post parameter with " << smootherPreOrPost << std::endl;
106 mueluss << "<Parameter name=\"smoother: pre or post\" type=\"string\" value=\"" << PreOrPost << "\"/>" << std::endl;
107 adaptingParamList.remove("smoother: pre or post", false);
108 }
109
110 // create smoother parameter list
111 if (PreOrPost != "both") {
112 mueluss << "<ParameterList name=\"smoother: " << PreOrPost << " params\">" << std::endl;
113 } else {
114 mueluss << "<ParameterList name=\"" << mode << " params\">" << std::endl;
115 }
116
117 // relaxation based smoothers:
118
119 if (valuestr == "jacobi" || valuestr == "gauss-seidel" || valuestr == "symmetric gauss-seidel") {
120 if (valuestr == "jacobi") {
121 mueluss << "<Parameter name=\"relaxation: type\" type=\"string\" value=\"Jacobi\"/>" << std::endl;
122 adaptingParamList.remove("relaxation: type", false);
123 }
124 if (valuestr == "gauss-seidel") {
125 mueluss << "<Parameter name=\"relaxation: type\" type=\"string\" value=\"Gauss-Seidel\"/>" << std::endl;
126 adaptingParamList.remove("relaxation: type", false);
127 }
128 if (valuestr == "symmetric gauss-seidel") {
129 mueluss << "<Parameter name=\"relaxation: type\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>" << std::endl;
130 adaptingParamList.remove("relaxation: type", false);
131 }
132 if (paramList.isParameter("smoother: sweeps")) {
133 mueluss << "<Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"" << paramList.get<int>("smoother: sweeps") << "\"/>" << std::endl;
134 adaptingParamList.remove("smoother: sweeps", false);
135 }
136 if (paramList.isParameter("smoother: damping factor")) {
137 mueluss << "<Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"" << paramList.get<double>("smoother: damping factor") << "\"/>" << std::endl;
138 adaptingParamList.remove("smoother: damping factor", false);
139 }
140 if (paramList.isParameter("smoother: use l1 Gauss-Seidel")) {
141 mueluss << "<Parameter name=\"relaxation: use l1\" type=\"bool\" value=\"" << paramList.get<bool>("smoother: use l1 Gauss-Seidel") << "\"/>" << std::endl;
142 adaptingParamList.remove("smoother: use l1 Gauss-Seidel", false);
143 }
144 }
145
146 // Chebyshev
147 if (valuestr == "chebyshev") {
148 if (paramList.isParameter("smoother: polynomial order")) {
149 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>("smoother: polynomial order") << "\"/>" << std::endl;
150 adaptingParamList.remove("smoother: polynomial order", false);
151 } else {
152 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"2\"/>" << std::endl;
153 }
154 if (paramList.isParameter("smoother: Chebyshev alpha")) {
155 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>("smoother: Chebyshev alpha") << "\"/>" << std::endl;
156 adaptingParamList.remove("smoother: Chebyshev alpha", false);
157 } else {
158 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"20\"/>" << std::endl;
159 adaptingParamList.remove("smoother: Chebyshev alpha", false);
160 }
161 if (paramList.isParameter("eigen-analysis: type")) {
162 mueluss << "<Parameter name=\"eigen-analysis: type\" type=\"string\" value=\"" << paramList.get<std::string>("eigen-analysis: type") << "\"/>" << std::endl;
163 adaptingParamList.remove("eigen-analysis: type", false);
164 } else {
165 mueluss << "<Parameter name=\"eigen-analysis: type\" type=\"string\" value=\"cg\"/>" << std::endl;
166 }
167 }
168
169 // MLS
170 if (valuestr == "mls") {
171 if (paramList.isParameter("smoother: MLS polynomial order")) {
172 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>("smoother: MLS polynomial order") << "\"/>" << std::endl;
173 adaptingParamList.remove("smoother: MLS polynomial order", false);
174 } else if (paramList.isParameter("smoother: polynomial order")) {
175 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>("smoother: polynomial order") << "\"/>" << std::endl;
176 adaptingParamList.remove("smoother: polynomial order", false);
177 } else {
178 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"2\"/>" << std::endl;
179 }
180 if (paramList.isParameter("smoother: MLS alpha")) {
181 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>("smoother: MLS alpha") << "\"/>" << std::endl;
182 adaptingParamList.remove("smoother: MLS alpha", false);
183 } else if (paramList.isParameter("smoother: Chebyshev alpha")) {
184 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>("smoother: Chebyshev alpha") << "\"/>" << std::endl;
185 adaptingParamList.remove("smoother: Chebyshev alpha", false);
186 } else {
187 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"20\"/>" << std::endl;
188 }
189 if (paramList.isParameter("eigen-analysis: type")) {
190 mueluss << "<Parameter name=\"eigen-analysis: type\" type=\"string\" value=\"" << paramList.get<std::string>("eigen-analysis: type") << "\"/>" << std::endl;
191 adaptingParamList.remove("eigen-analysis: type", false);
192 } else {
193 mueluss << "<Parameter name=\"eigen-analysis: type\" type=\"string\" value=\"cg\"/>" << std::endl;
194 }
195 }
196
197 if (valuestr == "hiptmair") {
198 std::string subSmootherType = "Chebyshev";
199 if (!is_coarse && paramList.isParameter("subsmoother: type"))
200 subSmootherType = paramList.get<std::string>("subsmoother: type");
201 if (is_coarse && paramList.isParameter("smoother: subsmoother type"))
202 subSmootherType = paramList.get<std::string>("smoother: subsmoother type");
203
204 std::string subSmootherIfpackType;
205
206 if (subSmootherType == "Chebyshev")
207 subSmootherIfpackType = "CHEBYSHEV";
208 else if (subSmootherType == "Jacobi" || subSmootherType == "Gauss-Seidel" || subSmootherType == "symmetric Gauss-Seidel") {
209 if (subSmootherType == "symmetric Gauss-Seidel") subSmootherType = "Symmetric Gauss-Seidel"; // FIXME
210 subSmootherIfpackType = "RELAXATION";
211 } else
212 TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::MLParameterListTranslator: unknown smoother type. '" << subSmootherType << "' not supported by MueLu.");
213
214 mueluss << "<Parameter name=\"hiptmair: smoother type 1\" type=\"string\" value=\"" << subSmootherIfpackType << "\"/>" << std::endl;
215 mueluss << "<Parameter name=\"hiptmair: smoother type 2\" type=\"string\" value=\"" << subSmootherIfpackType << "\"/>" << std::endl;
216
217 mueluss << "<ParameterList name=\"hiptmair: smoother list 1\">" << std::endl;
218 if (subSmootherType == "Chebyshev") {
219 std::string edge_sweeps = is_coarse ? "smoother: edge sweeps" : "subsmoother: edge sweeps";
220 std::string cheby_alpha = is_coarse ? "smoother: Chebyshev alpha" : "subsmoother: Chebyshev_alpha";
221
222 if (paramList.isParameter(edge_sweeps)) {
223 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>(edge_sweeps) << "\"/>" << std::endl;
224 adaptingParamList.remove("subsmoother: edge sweeps", false);
225 }
226 if (paramList.isParameter(cheby_alpha)) {
227 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>(cheby_alpha) << "\"/>" << std::endl;
228 }
229 } else {
230 std::string edge_sweeps = is_coarse ? "smoother: edge sweeps" : "subsmoother: edge sweeps";
231 std::string SGS_damping = is_coarse ? "smoother: SGS damping factor" : "subsmoother: SGS damping factor";
232
233 if (paramList.isParameter(edge_sweeps)) {
234 mueluss << "<Parameter name=\"relaxation: type\" type=\"string\" value=\"" << subSmootherType << "\"/>" << std::endl;
235 mueluss << "<Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"" << paramList.get<int>(edge_sweeps) << "\"/>" << std::endl;
236 adaptingParamList.remove(edge_sweeps, false);
237 }
238 if (paramList.isParameter(SGS_damping)) {
239 mueluss << "<Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"" << paramList.get<double>(SGS_damping) << "\"/>" << std::endl;
240 }
241 }
242 mueluss << "</ParameterList>" << std::endl;
243
244 mueluss << "<ParameterList name=\"hiptmair: smoother list 2\">" << std::endl;
245 if (subSmootherType == "Chebyshev") {
246 std::string node_sweeps = is_coarse ? "smoother: node sweeps" : "subsmoother: node sweeps";
247 std::string cheby_alpha = is_coarse ? "smoother: Chebyshev alpha" : "subsmoother: Chebyshev_alpha";
248 if (paramList.isParameter(node_sweeps)) {
249 mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>(node_sweeps) << "\"/>" << std::endl;
250 adaptingParamList.remove("subsmoother: node sweeps", false);
251 }
252 if (paramList.isParameter(cheby_alpha)) {
253 mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>(cheby_alpha) << "\"/>" << std::endl;
254 adaptingParamList.remove("subsmoother: Chebyshev alpha", false);
255 }
256 } else {
257 std::string node_sweeps = is_coarse ? "smoother: node sweeps" : "subsmoother: node sweeps";
258 std::string SGS_damping = is_coarse ? "smoother: SGS damping factor" : "subsmoother: SGS damping factor";
259
260 if (paramList.isParameter(node_sweeps)) {
261 mueluss << "<Parameter name=\"relaxation: type\" type=\"string\" value=\"" << subSmootherType << "\"/>" << std::endl;
262 mueluss << "<Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"" << paramList.get<int>(node_sweeps) << "\"/>" << std::endl;
263 adaptingParamList.remove("subsmoother: node sweeps", false);
264 }
265 if (paramList.isParameter(SGS_damping)) {
266 mueluss << "<Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"" << paramList.get<double>(SGS_damping) << "\"/>" << std::endl;
267 adaptingParamList.remove("subsmoother: SGS damping factor", false);
268 }
269 }
270 mueluss << "</ParameterList>" << std::endl;
271 }
272
273 // parameters for ILU based preconditioners
274 if (valuestr == "ifpack") {
275 // add Ifpack parameters
276 if (paramList.isParameter("smoother: ifpack overlap")) {
277 mueluss << "<Parameter name=\"partitioner: overlap\" type=\"int\" value=\"" << paramList.get<int>("smoother: ifpack overlap") << "\"/>" << std::endl;
278 adaptingParamList.remove("smoother: ifpack overlap", false);
279 }
280 if (paramList.isParameter("smoother: ifpack level-of-fill")) {
281 mueluss << "<Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"" << paramList.get<int>("smoother: ifpack level-of-fill") << "\"/>" << std::endl;
282 adaptingParamList.remove("smoother: ifpack level-of-fill", false);
283 }
284 if (paramList.isParameter("smoother: ifpack absolute threshold")) {
285 mueluss << "<Parameter name=\"fact: absolute threshold\" type=\"int\" value=\"" << paramList.get<double>("smoother: ifpack absolute threshold") << "\"/>" << std::endl;
286 adaptingParamList.remove("smoother: ifpack absolute threshold", false);
287 }
288 if (paramList.isParameter("smoother: ifpack relative threshold")) {
289 mueluss << "<Parameter name=\"fact: relative threshold\" type=\"int\" value=\"" << paramList.get<double>("smoother: ifpack relative threshold") << "\"/>" << std::endl;
290 adaptingParamList.remove("smoother: ifpack relative threshold", false);
291 }
292 }
293
294 mueluss << "</ParameterList>" << std::endl;
295
296 // max coarse level size parameter (outside of smoother parameter lists)
297 if (paramList.isParameter("smoother: max size")) {
298 mueluss << "<Parameter name=\"coarse: max size\" type=\"int\" value=\"" << paramList.get<int>("smoother: max size") << "\"/>" << std::endl;
299 adaptingParamList.remove("smoother: max size", false);
300 }
301
302 return mueluss.str();
303}
304
305Teuchos::RCP<Teuchos::ParameterList> ML2MueLuParameterTranslator::SetParameterList(const Teuchos::ParameterList& paramList_in, const std::string& defaultVals) {
306 Teuchos::ParameterList paramList = paramList_in;
307
308 RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); // TODO: use internal out (GetOStream())
309 // ML counts levels slightly differently than MueLu does so "repartition: start level" is off by one
310 // ML defaults to "1" if we don't ask for anything else and that needs to map to "2"
311 if (paramList.isParameter("repartition: start level")) {
312 paramList.set("repartition: start level", paramList.get<int>("repartition: start level") + 1);
313 } else {
314 paramList.set("repartition: start level", 2);
315 }
316
317 // ML sets this to 5000
318 if (!paramList.isParameter("repartition: put on single proc")) {
319 paramList.set("repartition: put on single proc", 5000);
320 }
321
322 // Set the default values
323 if (defaultVals != "") {
324 TEUCHOS_TEST_FOR_EXCEPTION(defaultVals != "SA" && defaultVals != "NSSA" && defaultVals != "refmaxwell" && defaultVals != "Maxwell", Exceptions::RuntimeError,
325 "MueLu::ML2MueLuParameterTranslator: only \"SA\", \"NSSA\", \"refmaxwell\" and \"Maxwell\" allowed as options for ML default parameters.");
326 Teuchos::ParameterList ML_defaultlist;
327 if (defaultVals == "refmaxwell")
328 SetDefaultsRefMaxwell(ML_defaultlist);
329 else
330 SetDefaults(defaultVals, ML_defaultlist);
331
332 // merge user parameters with default parameters
333 MueLu::MergeParameterList(paramList_in, ML_defaultlist, true);
334 paramList = ML_defaultlist;
335 }
336
337 //
338 // Move smoothers/aggregation/coarse parameters to sublists
339 //
340
341 // ML allows to have level-specific smoothers/aggregation/coarse parameters at the top level of the list or/and defined in sublists:
342 // See also: ML Guide section 6.4.1, MueLu::CreateSublists, ML_CreateSublists
343 ParameterList paramListWithSubList;
344 MueLu::CreateSublists(paramList, paramListWithSubList);
345 paramList = paramListWithSubList; // swap
346 Teuchos::ParameterList adaptingParamList = paramList; // copy of paramList which is used to removed already interpreted parameters
347
348 {
349 // Special handling of ML's aux aggregation
350 //
351 // In ML, when "aggregation: aux: enable" == true, the threshold
352 // is set via "aggregation: aux: threshold" instead of
353 // "aggregation: threshold". In MueLu, we use "aggregation: drop
354 // tol" regardless of "sa: use filtering". So depending on
355 // "aggregation: aux: enable" we use either one or the other
356 // threshold to set "aggregation: drop tol".
357 if (paramListWithSubList.isParameter("aggregation: aux: enable") && paramListWithSubList.get<bool>("aggregation: aux: enable")) {
358 if (paramListWithSubList.isParameter("aggregation: aux: threshold")) {
359 paramListWithSubList.set("aggregation: threshold", paramListWithSubList.get<double>("aggregation: aux: threshold"));
360 paramListWithSubList.remove("aggregation: aux: threshold");
361 }
362 }
363 }
364
365 // stringstream for concatenating xml parameter strings.
366 std::stringstream mueluss;
367 // create surrounding MueLu parameter list
368 mueluss << "<ParameterList name=\"MueLu\">" << std::endl;
369
370 // make sure that MueLu's phase1 matches ML's
371 mueluss << "<Parameter name=\"aggregation: match ML phase1\" type=\"bool\" value=\"true\"/>" << std::endl;
372
373 // make sure that MueLu's phase2a matches ML's
374 mueluss << "<Parameter name=\"aggregation: match ML phase2a\" type=\"bool\" value=\"true\"/>" << std::endl;
375
376 // make sure that MueLu's phase2b matches ML's
377 mueluss << "<Parameter name=\"aggregation: match ML phase2b\" type=\"bool\" value=\"true\"/>" << std::endl;
378
379 // make sure that MueLu's drop tol matches ML's
380 mueluss << "<Parameter name=\"aggregation: use ml scaling of drop tol\" type=\"bool\" value=\"true\"/>" << std::endl;
381
382 // make sure that MueLu's SaP diagonal behavior matches ML's
383 mueluss << "<Parameter name=\"sa: diagonal replacement tolerance\" type=\"double\" value=\"0.0\"/>" << std::endl;
384
385 // We allow MueLu parameter to be passed through the translation.
386 // We split them off and then check if we have conflicts.
387 Teuchos::ParameterList mueluList;
388
389 // loop over all ML parameters in provided parameter list
390 for (ParameterList::ConstIterator param = paramListWithSubList.begin(); param != paramListWithSubList.end(); ++param) {
391 // extract ML parameter name
392 const std::string& pname = paramListWithSubList.name(param);
393
394 // Short circuit the "parameterlist: syntax" parameter
395 // We want to remove this to make sure that createXpetraPreconditioner doesn't re-call translate()
396 if (pname == "parameterlist: syntax") {
397 continue;
398 }
399
400 // extract corresponding (ML) value
401 // remove ParameterList specific information from result string
402 std::stringstream valuess;
403 valuess << paramList.entry(param);
404 std::string valuestr = valuess.str();
405 replaceAll(valuestr, "[unused]", "");
406 replaceAll(valuestr, "[default]", "");
407 valuestr = trim(valuestr);
408
409 // transform ML parameter to corresponding MueLu parameter and generate XML string
410 std::string valueInterpreterStr = "\"" + valuestr + "\"";
411 std::string ret = MasterList::interpretParameterName(MasterList::ML2MueLu(pname), valueInterpreterStr);
412 bool hasBeenProcessed = false;
413
414 if ((pname == "aggregation: aux: enable") && (paramListWithSubList.get<bool>("aggregation: aux: enable"))) {
415 mueluss << "<Parameter name=\"aggregation: drop scheme\" type=\"string\" value=\""
416 << "distance laplacian"
417 << "\"/>" << std::endl;
418 }
419
420 // special handling for verbosity level
421 if (pname == "ML output") {
422 // Translate verbosity parameter
423 int verbosityLevel = std::stoi(valuestr);
424 std::string eVerbLevel = "none";
425 if (verbosityLevel == 0) eVerbLevel = "none";
426 if (verbosityLevel >= 1) eVerbLevel = "low";
427 if (verbosityLevel >= 5) eVerbLevel = "medium";
428 if (verbosityLevel >= 10) eVerbLevel = "high";
429 if (verbosityLevel >= 11) eVerbLevel = "extreme";
430 if (verbosityLevel >= 42) eVerbLevel = "test";
431 if (verbosityLevel >= 666) eVerbLevel = "interfacetest";
432 mueluss << "<Parameter name=\"verbosity\" type=\"string\" value=\"" << eVerbLevel << "\"/>" << std::endl;
433 continue;
434 }
435
436 // add XML string
437 if (ret != "") {
438 mueluss << ret << std::endl;
439
440 // remove parameter from ML parameter list
441 adaptingParamList.remove(pname, false);
442
443 hasBeenProcessed = true;
444 }
445
446 // special handling for energy minimization
447 // TAW: this is not optimal for symmetric problems but at least works.
448 // for symmetric problems the "energy minimization" parameter should not exist anyway...
449 if (pname == "energy minimization: enable") {
450 mueluss << "<Parameter name=\"problem: symmetric\" type=\"bool\" value=\"false\"/>" << std::endl;
451 mueluss << "<Parameter name=\"transpose: use implicit\" type=\"bool\" value=\"false\"/>" << std::endl;
452 hasBeenProcessed = true;
453 }
454
455 // special handling for smoothers
456 if (pname == "smoother: type") {
457 mueluss << GetSmootherFactory(paramList, adaptingParamList, pname, valuestr);
458 hasBeenProcessed = true;
459 }
460
461 // special handling for level-specific smoothers
462 if (pname.find("smoother: list (level", 0) == 0) {
463 // Scan pname (ex: pname="smoother: type (level 2)")
464 std::string type, option;
465 int levelID = -1;
466 {
467 typedef Teuchos::ArrayRCP<char>::size_type size_type;
468 Teuchos::Array<char> ctype(size_type(pname.size() + 1));
469 Teuchos::Array<char> coption(size_type(pname.size() + 1));
470
471 int matched = sscanf(pname.c_str(), "%s %[^(](level %d)", ctype.getRawPtr(), coption.getRawPtr(), &levelID); // use [^(] instead of %s to allow for strings with white-spaces (ex: "ifpack list")
472 type = std::string(ctype.getRawPtr());
473 option = std::string(coption.getRawPtr());
474 option.resize(option.size() - 1); // remove final white-space
475
476 if (matched != 3 || (type != "smoother:")) {
477 TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "MueLu::CreateSublist(), Line " << __LINE__ << ". "
478 << "Error in creating level-specific sublists" << std::endl
479 << "Offending parameter: " << pname << std::endl);
480 }
481
482 mueluss << "<ParameterList name=\"level " << levelID << "\">" << std::endl;
483 mueluss << GetSmootherFactory(paramList.sublist(pname), adaptingParamList.sublist(pname), "smoother: type", paramList.sublist(pname).get<std::string>("smoother: type"));
484 mueluss << "</ParameterList>" << std::endl;
485 }
486 hasBeenProcessed = true;
487 }
488 // special handling for coarse level
489 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter("coarse: type"), Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter::Setup(): The parameter \"coarse: type\" should not exist but being stored in \"coarse: list\" instead.");
490
491 if (pname == "coarse: list") {
492 // interpret smoother/coarse solver data.
493 // Note, that we inspect the "coarse: list" sublist to define the "coarse" smoother/solver
494 // Be aware, that MueLu::CreateSublists renames the prefix of the parameters in the "coarse: list" from "coarse" to "smoother".
495 // Therefore, we have to check the values of the "smoother" parameters
496
497 // DO we have a coarse list / smoother type? If not, assume KLU
498 std::string coarse_smoother = "Amesos-KLU";
499 if (paramList.sublist("coarse: list").isParameter("smoother: type"))
500 coarse_smoother = paramList.sublist("coarse: list").get<std::string>("smoother: type");
501
502 mueluss << GetSmootherFactory(paramList.sublist("coarse: list"), adaptingParamList.sublist("coarse: list"), "coarse: type", coarse_smoother);
503 hasBeenProcessed = true;
504 }
505
506 if (pname == "aggregation: type") {
507 if (valuestr == "Uncoupled")
508 mueluss << "<Parameter name=\"aggregation: type\" type=\"string\" value=\"uncoupled\"/>" << std::endl;
509 else if (valuestr == "Uncoupled-MIS") {
510 mueluss << "<Parameter name=\"aggregation: type\" type=\"string\" value=\"uncoupled\"/>" << std::endl;
511 mueluss << "<Parameter name=\"aggregation: coloring algorithm\" type=\"string\" value=\"mis2 aggregation\"/>" << std::endl;
512 mueluss << "<Parameter name=\"aggregation: backend\" type=\"string\" value=\"kokkos\"/>" << std::endl;
513 } else
514 TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Only \"Uncoupled\" aggregation is supported, not \"" << valuestr << "\"\n");
515 hasBeenProcessed = true;
516 }
517
518 if (pname == "problem: type" ||
519 pname == "smoother: sweeps" ||
520 pname == "smoother: damping factor" ||
521 pname == "smoother: pre or post" ||
522 pname == "coarse: max size")
523 hasBeenProcessed = true;
524
525 if (paramList.isSublist(pname))
526 hasBeenProcessed = true;
527
528 if (!hasBeenProcessed) {
529 std::cout << "Could not translate \"" << pname << "\" = \"" << valuestr << "\"\n";
530 if (MasterList::List()->isParameter(pname)) {
531 std::cout << "Is valid MueLu parameter \"" << pname << "\"\n";
532 mueluList.setEntry(pname, paramList.entry(param));
533 }
534 }
535 } // for
536 mueluss << "</ParameterList>" << std::endl;
537
538 auto translatedList = Teuchos::getParametersFromXmlString(mueluss.str());
539
540 std::cout << "\n\ntranslatedList " << *translatedList << std::endl
541 << "muelu list " << mueluList << std::endl
542 << std::endl;
543
544 // Check that none of the MueLu parameters that were passed in clash with interpreted ML parameters
545 for (auto it = mueluList.begin(); it != mueluList.end(); ++it) {
546 auto& pname = mueluList.name(it);
547 TEUCHOS_TEST_FOR_EXCEPTION(translatedList->isParameter(pname), MueLu::Exceptions::RuntimeError, "The parameter \"" << pname << "\" has been set both using ML and MueLu parameter names.");
548 }
549 // Add the MueLu parameters to the translated list
550 translatedList->setParameters(mueluList);
551
552 return translatedList;
553}
554
555static void ML_OverwriteDefaults(ParameterList& inList, ParameterList& List, bool OverWrite) {
556 ParameterList* coarseList = 0;
557 // Don't create the coarse list if it doesn't already exist!
558 if (inList.isSublist("coarse: list"))
559 coarseList = &(inList.sublist("coarse: list"));
560 for (ParameterList::ConstIterator param = List.begin(); param != List.end(); param++) {
561 std::string pname = List.name(param);
562 if (coarseList && pname.find("coarse: ", 0) != std::string::npos) {
563 if (!coarseList->isParameter(pname) || OverWrite)
564 coarseList->setEntry(pname, List.entry(param));
565 } else if (!inList.isParameter(pname) || OverWrite) {
566 inList.setEntry(pname, List.entry(param));
567 }
568 }
569} // ML_OverwriteDefaults()
570
571static int UpdateList(Teuchos::ParameterList& source, Teuchos::ParameterList& dest, bool OverWrite) {
572 for (Teuchos::ParameterList::ConstIterator param = source.begin(); param != source.end(); param++)
573 if (dest.isParameter(source.name(param)) == false || OverWrite)
574 dest.setEntry(source.name(param), source.entry(param));
575 return 0;
576}
577
578int ML2MueLuParameterTranslator::SetDefaults(std::string ProblemType, Teuchos::ParameterList& List,
579 int* ioptions, double* iparams, const bool OverWrite) {
580 Teuchos::RCP<std::vector<int> > options;
581 Teuchos::RCP<std::vector<double> > params;
582
583 // Taken from AztecOO
584 const int MUELU_AZ_OPTIONS_SIZE = 47;
585 const int MUELU_AZ_PARAMS_SIZE = 30;
586
587 /*bool SetDefaults = false;
588 if (ioptions == NULL || iparams == NULL)
589 SetDefaults = true;*/
590
591 if (ioptions == NULL)
592 options = rcp(new std::vector<int>(MUELU_AZ_OPTIONS_SIZE));
593 else
594 options = rcp(new std::vector<int>(ioptions, ioptions + MUELU_AZ_OPTIONS_SIZE));
595 if (iparams == NULL)
596 params = rcp(new std::vector<double>(MUELU_AZ_PARAMS_SIZE));
597 else
598 params = rcp(new std::vector<double>(iparams, iparams + MUELU_AZ_PARAMS_SIZE));
599
600 // if (SetDefaults)
601 // AZ_defaults(&(*options)[0],&(*params)[0]);
602
603 if (ProblemType == "SA") {
604 SetDefaultsSA(List, options, params, OverWrite);
605 } else if (ProblemType == "DD") {
606 SetDefaultsDD(List, options, params, OverWrite);
607 } else if (ProblemType == "DD-ML") {
608 SetDefaultsDD_3Levels(List, options, params, OverWrite);
609 } else if (ProblemType == "maxwell" || ProblemType == "Maxwell") {
610 SetDefaultsMaxwell(List, options, params, OverWrite);
611 } else if (ProblemType == "NSSA") {
612 SetDefaultsNSSA(List, options, params, OverWrite);
613 } else if (ProblemType == "DD-ML-LU") {
614 SetDefaultsDD_3Levels_LU(List, options, params, OverWrite);
615 } else if (ProblemType == "DD-LU") {
616 SetDefaultsDD_LU(List, options, params, OverWrite);
617 } else if (ProblemType == "Classical-AMG") {
618 SetDefaultsClassicalAMG(List, options, params, OverWrite);
619 } else {
620 std::cerr << "ERROR: Wrong input parameter in `SetDefaults' ("
621 << ProblemType << "). Should be: " << std::endl
622 << "ERROR: <SA> / <DD> / <DD-ML> / <maxwell>" << std::endl;
623 }
624 return (0);
625}
626
628 Teuchos::RCP<std::vector<int> >& /* options */,
629 Teuchos::RCP<std::vector<double> >& /* params */,
630 bool OverWrite) {
631 ParameterList List;
632 inList.setName("SA default values");
633 List.set("default values", "SA");
634 List.set("max levels", 10);
635 List.set("prec type", "MGV");
636 List.set("increasing or decreasing", "increasing");
637
638 List.set("aggregation: type", "Uncoupled-MIS");
639 List.set("aggregation: damping factor", 1.333);
640 List.set("eigen-analysis: type", "cg");
641 List.set("eigen-analysis: iterations", 10);
642
643 List.set("smoother: sweeps", 2);
644 List.set("smoother: damping factor", 1.0);
645 List.set("smoother: pre or post", "both");
646 List.set("smoother: type", "symmetric Gauss-Seidel");
647
648 List.set("coarse: type", "Amesos-KLU");
649 List.set("coarse: max size", 128);
650 List.set("coarse: pre or post", "post");
651 List.set("coarse: sweeps", 1);
652 List.set("coarse: split communicator", false);
653
654 // Make sure we know this follows the ML defaults
655 List.set("parameterlist: syntax", "ml");
656
657 ML_OverwriteDefaults(inList, List, OverWrite);
658 return 0;
659} // ML2MueLuParameterTranslator::SetDefaultsSA()
660
662 Teuchos::RCP<std::vector<int> >& /*options*/,
663 Teuchos::RCP<std::vector<double> >& /*params*/,
664 bool OverWrite) {
665 ParameterList List;
666
667 inList.setName("DD default values");
668 List.set("default values", "DD");
669 List.set("max levels", 2);
670 List.set("prec type", "MGV");
671 List.set("increasing or decreasing", "increasing");
672
673 List.set("aggregation: type", "METIS");
674 List.set("aggregation: local aggregates", 1);
675 List.set("aggregation: damping factor", 1.333);
676 List.set("eigen-analysis: type", "power-method");
677 List.set("eigen-analysis: iterations", 20);
678
679 List.set("smoother: sweeps", 1);
680 List.set("smoother: pre or post", "both");
681 /*#ifdef HAVE_ML_AZTECOO
682 List.set("smoother: type","Aztec");
683 (*options)[AZ_precond] = AZ_dom_decomp;
684 (*options)[AZ_subdomain_solve] = AZ_ilu;
685 List.set("smoother: Aztec options",options);
686 List.set("smoother: Aztec params",params);
687 List.set("smoother: Aztec as solver",false);
688 #endif*/
689
690 List.set("coarse: type", "Amesos-KLU");
691 List.set("coarse: max size", 128);
692 List.set("coarse: pre or post", "post");
693 List.set("coarse: sweeps", 1);
694
695 // Make sure we know this follows the ML defaults
696 List.set("parameterlist: syntax", "ml");
697
698 ML_OverwriteDefaults(inList, List, OverWrite);
699 return 0;
700} // ML2MueLuParameterTranslator::SetDefaultsDD()
701
703 Teuchos::RCP<std::vector<int> >& /*options*/,
704 Teuchos::RCP<std::vector<double> >& /*params*/,
705 bool OverWrite) {
706 ParameterList List;
707
708 inList.setName("DD-ML default values");
709 List.set("default values", "DD-ML");
710
711 List.set("max levels", 3);
712 List.set("prec type", "MGV");
713 List.set("increasing or decreasing", "increasing");
714
715 List.set("aggregation: type", "METIS");
716 List.set("aggregation: nodes per aggregate", 512);
717 List.set("aggregation: next-level aggregates per process", 128);
718 List.set("aggregation: damping factor", 1.333);
719 List.set("eigen-analysis: type", "power-method");
720 List.set("eigen-analysis: iterations", 20);
721
722 List.set("smoother: sweeps", 1);
723 List.set("smoother: pre or post", "both");
724 /*#ifdef HAVE_ML_AZTECOO
725 List.set("smoother: type","Aztec");
726 (*options)[AZ_precond] = AZ_dom_decomp;
727 (*options)[AZ_subdomain_solve] = AZ_ilu;
728 List.set("smoother: Aztec options",options);
729 List.set("smoother: Aztec params",params);
730 List.set("smoother: Aztec as solver",false);
731 #endif*/
732
733 List.set("coarse: type", "Amesos-KLU");
734 List.set("coarse: max size", 128);
735 List.set("coarse: pre or post", "post");
736 List.set("coarse: sweeps", 1);
737
738 // Make sure we know this follows the ML defaults
739 List.set("parameterlist: syntax", "ml");
740
741 ML_OverwriteDefaults(inList, List, OverWrite);
742 return 0;
743} // ML2MueLuParameterTranslator::SetDefaultsDD_3Levels()
744
746 Teuchos::RCP<std::vector<int> >& /* options */,
747 Teuchos::RCP<std::vector<double> >& /* params */,
748 bool OverWrite) {
749 ParameterList List;
750
751 inList.setName("Maxwell default values");
752 List.set("default values", "maxwell");
753 List.set("max levels", 10);
754 List.set("prec type", "MGV");
755 List.set("increasing or decreasing", "decreasing");
756
757 List.set("aggregation: type", "Uncoupled-MIS");
758 List.set("aggregation: damping factor", 1.333);
759 List.set("eigen-analysis: type", "cg");
760 List.set("eigen-analysis: iterations", 10);
761 // dropping threshold for small entries in edge prolongator
762 List.set("aggregation: edge prolongator drop threshold", 0.0);
763
764 List.set("smoother: sweeps", 1);
765 List.set("smoother: damping factor", 1.0);
766 List.set("smoother: pre or post", "both");
767 List.set("smoother: type", "Hiptmair");
768 List.set("smoother: Hiptmair efficient symmetric", true);
769 List.set("subsmoother: type", "Chebyshev"); // Hiptmair subsmoother options
770 List.set("subsmoother: Chebyshev alpha", 20.0);
771 List.set("subsmoother: node sweeps", 4);
772 List.set("subsmoother: edge sweeps", 4);
773
774 // direct solver on coarse problem
775 List.set("coarse: type", "Amesos-KLU");
776 List.set("coarse: max size", 128);
777 List.set("coarse: pre or post", "post");
778 List.set("coarse: sweeps", 1);
779
780 // Make sure we know this follows the ML defaults
781 List.set("parameterlist: syntax", "ml");
782
783 ML_OverwriteDefaults(inList, List, OverWrite);
784 return 0;
785} // ML2MueLuParameterTranslator::SetDefaultsMaxwell()
786
788 Teuchos::RCP<std::vector<int> >& /* options */,
789 Teuchos::RCP<std::vector<double> >& /* params */,
790 bool OverWrite) {
791 ParameterList List;
792
793 inList.setName("NSSA default values");
794 List.set("default values", "NSSA");
795 List.set("max levels", 10);
796 List.set("prec type", "MGW");
797 List.set("increasing or decreasing", "increasing");
798
799 List.set("aggregation: type", "Uncoupled-MIS");
800 List.set("energy minimization: enable", true);
801 List.set("eigen-analysis: type", "power-method");
802 List.set("eigen-analysis: iterations", 20);
803
804 List.set("smoother: sweeps", 4);
805 List.set("smoother: damping factor", .67);
806 List.set("smoother: pre or post", "post");
807 List.set("smoother: type", "symmetric Gauss-Seidel");
808
809 List.set("coarse: type", "Amesos-KLU");
810 List.set("coarse: max size", 256);
811 List.set("coarse: pre or post", "post");
812 List.set("coarse: sweeps", 1);
813
814 // Make sure we know this follows the ML defaults
815 List.set("parameterlist: syntax", "ml");
816
817 ML_OverwriteDefaults(inList, List, OverWrite);
818 return 0;
819} // ML2MueLuParameterTranslator::SetDefaultsNSSA()
820
822 Teuchos::RCP<std::vector<int> >& /*options*/,
823 Teuchos::RCP<std::vector<double> >& /*params*/,
824 bool OverWrite) {
825 ParameterList List;
826
827 inList.setName("DD-LU default values");
828 List.set("default values", "DD-LU");
829 List.set("max levels", 2);
830 List.set("prec type", "MGV");
831 List.set("increasing or decreasing", "increasing");
832
833 List.set("aggregation: type", "METIS");
834 List.set("aggregation: local aggregates", 1);
835 List.set("aggregation: damping factor", 1.333);
836 List.set("eigen-analysis: type", "power-method");
837 List.set("eigen-analysis: iterations", 20);
838
839 List.set("smoother: sweeps", 1);
840 List.set("smoother: pre or post", "both");
841
842 /*#ifdef HAVE_ML_AZTECOO
843 List.set("smoother: type","Aztec");
844 (*options)[AZ_precond] = AZ_dom_decomp;
845 (*options)[AZ_subdomain_solve] = AZ_lu;
846 List.set("smoother: Aztec options",options);
847 List.set("smoother: Aztec params",params);
848 List.set("smoother: Aztec as solver",false);
849 #endif*/
850
851 List.set("coarse: type", "Amesos-KLU");
852 List.set("coarse: max size", 128);
853 List.set("coarse: pre or post", "post");
854 List.set("coarse: sweeps", 1);
855
856 // Make sure we know this follows the ML defaults
857 List.set("parameterlist: syntax", "ml");
858
859 ML_OverwriteDefaults(inList, List, OverWrite);
860 return 0;
861} // ML2MueLuParameterTranslator::SetDefaultsDD_LU()
862
864 Teuchos::RCP<std::vector<int> >& /*options*/,
865 Teuchos::RCP<std::vector<double> >& /*params*/,
866 bool OverWrite) {
867 ParameterList List;
868
869 inList.setName("DD-ML-LU default values");
870 List.set("default values", "DD-ML-LU");
871 List.set("max levels", 3);
872 List.set("prec type", "MGV");
873 List.set("increasing or decreasing", "increasing");
874
875 List.set("aggregation: type", "METIS");
876 List.set("aggregation: nodes per aggregate", 512);
877 List.set("aggregation: next-level aggregates per process", 128);
878 List.set("aggregation: damping factor", 1.333);
879
880 List.set("smoother: sweeps", 1);
881 List.set("smoother: pre or post", "both");
882 /*#ifdef HAVE_ML_AZTECOO
883 List.set("smoother: type","Aztec");
884 (*options)[AZ_precond] = AZ_dom_decomp;
885 (*options)[AZ_subdomain_solve] = AZ_lu;
886 List.set("smoother: Aztec options",options);
887 List.set("smoother: Aztec params",params);
888 List.set("smoother: Aztec as solver",false);
889 #endif*/
890 List.set("coarse: type", "Amesos-KLU");
891 List.set("coarse: max size", 128);
892 List.set("coarse: pre or post", "post");
893 List.set("coarse: sweeps", 1);
894
895 ML_OverwriteDefaults(inList, List, OverWrite);
896 return 0;
897} // ML2MueLuParameterTranslator::SetDefaultsDD_3Levels_LU()
898
900 Teuchos::RCP<std::vector<int> >& /* options */,
901 Teuchos::RCP<std::vector<double> >& /* params */,
902 bool OverWrite) {
903 ParameterList List;
904
905 inList.setName("Classical-AMG default values");
906 List.set("default values", "Classical-AMG");
907 List.set("max levels", 10);
908 List.set("prec type", "MGV");
909 List.set("increasing or decreasing", "increasing");
910 List.set("smoother: sweeps", 2);
911 List.set("smoother: damping factor", 1.0);
912 List.set("smoother: pre or post", "both");
913 List.set("smoother: type", "symmetric Gauss-Seidel");
914
915 List.set("coarse: type", "Amesos-KLU");
916 List.set("coarse: max size", 128);
917 List.set("coarse: pre or post", "post");
918 List.set("coarse: sweeps", 1);
919
920 // Make sure we know this follows the ML defaults
921 List.set("parameterlist: syntax", "ml");
922
923 ML_OverwriteDefaults(inList, List, OverWrite);
924 return 0;
925} // ML2MueLuParameterTranslator::SetDefaultsClassicalAMG()
926
927int ML2MueLuParameterTranslator::SetDefaultsRefMaxwell(Teuchos::ParameterList& inList, bool OverWrite) {
928 /* Sublists */
929 Teuchos::ParameterList ListRF, List11, List11c, List22, dummy;
930 Teuchos::ParameterList& List11_ = inList.sublist("refmaxwell: 11list");
931 Teuchos::ParameterList& List22_ = inList.sublist("refmaxwell: 22list");
932 Teuchos::ParameterList& List11c_ = List11_.sublist("edge matrix free: coarse");
933
934 /* Build Teuchos List: (1,1) coarse */
935 SetDefaults("SA", List11c);
936 List11c.remove("parameterlist: syntax");
937 List11c.set("cycle applications", 1);
938 List11c.set("smoother: type", "Chebyshev");
939 List11c.set("aggregation: threshold", .01);
940 List11c.set("coarse: type", "Amesos-KLU");
941 List11c.set("ML label", "coarse (1,1) block");
942 UpdateList(List11c, List11c_, OverWrite);
943
944 /* Build Teuchos List: (1,1) */
945 SetDefaults("SA", List11);
946 List11.remove("parameterlist: syntax");
947 List11.set("cycle applications", 1);
948 List11.set("aggregation: type", "Uncoupled");
949 List11.set("smoother: sweeps", 0);
950 List11.set("aggregation: damping factor", 0.0);
951 List11.set("edge matrix free: coarse", List11c);
952 List11.set("aggregation: threshold", .01);
953 UpdateList(List11, List11_, OverWrite);
954
955 /* Build Teuchos List: (2,2) */
956 SetDefaults("SA", List22);
957 List22.remove("parameterlist: syntax");
958 List22.set("cycle applications", 1);
959 List22.set("smoother: type", "Chebyshev");
960 List22.set("aggregation: type", "Uncoupled");
961 List22.set("aggregation: threshold", .01);
962 List22.set("coarse: type", "Amesos-KLU");
963 List22.set("ML label", "(2,2) block");
964
965 // This line is commented out due to IFPACK issues
966 // List22.set("smoother: sweeps (level 0)",0);
967 UpdateList(List22, List22_, OverWrite);
968
969 /* Build Teuchos List: Overall */
970 SetDefaults("maxwell", ListRF, 0, 0, false);
971 ListRF.set("smoother: type", "Chebyshev");
972 ListRF.set("smoother: sweeps", 2);
973 ListRF.set("refmaxwell: 11solver", "edge matrix free"); // either "edge matrix free" or "sa"
974 ListRF.set("refmaxwell: 11list", List11);
975 ListRF.set("refmaxwell: 22solver", "multilevel");
976 ListRF.set("refmaxwell: 22list", List22);
977 ListRF.set("refmaxwell: mode", "additive");
978 ListRF.set("default values", "RefMaxwell");
979 ListRF.set("zero starting solution", false);
980
981 // Make sure we know this follows the ML defaults
982 ListRF.set("parameterlist: syntax", "ml");
983
984 UpdateList(ListRF, inList, OverWrite);
985
986 return 0;
987} /*end SetDefaultsRefMaxwell*/
988
989} // namespace MueLu
Exception throws to report errors in the internal logical of the program.
static int SetDefaultsClassicalAMG(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets defaults for classical amg.
static int SetDefaultsNSSA(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets defaults for energy minimization preconditioning for nonsymmetric problems.
static int SetDefaultsSA(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for classical smoothed aggregation.
static int SetDefaultsDD_3Levels_LU(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 3-level domain decomposition preconditioners with LU.
static int SetDefaultsMaxwell(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for the eddy current equations equations.
static Teuchos::RCP< Teuchos::ParameterList > SetParameterList(const Teuchos::ParameterList &paramList_in, const std::string &defaultVals)
: Interpret parameter list
static int SetDefaultsDD(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 2-level domain decomposition preconditioners.
static int SetDefaultsRefMaxwell(Teuchos::ParameterList &inList, bool OverWrite=true)
Sets defaults for RefMaxwell / Maxwell2.
static int SetDefaults(std::string ProblemType, Teuchos::ParameterList &List, int *options=0, double *params=0, const bool OverWrite=true)
Sets ML's (not MueLu's) default parameters for aggregation-based preconditioners.
static int SetDefaultsDD_LU(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 2-level domain decomposition preconditioners,...
static std::string GetSmootherFactory(const Teuchos::ParameterList &paramList, Teuchos::ParameterList &adaptingParamList, const std::string &pname, const std::string &value)
: Helper function which translates ML smoother/solver paramters to MueLu XML string
static int SetDefaultsDD_3Levels(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 3-level domain decomposition preconditioners.
static std::string ML2MueLu(const std::string &name)
Translate ML parameter to corresponding MueLu parameter.
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
static std::string interpretParameterName(const std::string &name, const std::string &value)
Namespace for MueLu classes and methods.
void CreateSublists(const Teuchos::ParameterList &List, Teuchos::ParameterList &newList)
static int UpdateList(Teuchos::ParameterList &source, Teuchos::ParameterList &dest, bool OverWrite)
void replaceAll(std::string &str, const std::string &from, const std::string &to)
void MergeParameterList(const Teuchos::ParameterList &source, Teuchos::ParameterList &dest, bool overWrite)
: merge two parameter lists
static void ML_OverwriteDefaults(ParameterList &inList, ParameterList &List, bool OverWrite)