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 paramList.set("repartition: partitioner", "zoltan");
317
318 // ML sets this to 5000
319 if (!paramList.isParameter("repartition: put on single proc")) {
320 paramList.set("repartition: put on single proc", 5000);
321 }
322
323 // Set the default values
324 if (defaultVals != "") {
325 TEUCHOS_TEST_FOR_EXCEPTION(defaultVals != "SA" && defaultVals != "NSSA" && defaultVals != "refmaxwell" && defaultVals != "Maxwell", Exceptions::RuntimeError,
326 "MueLu::ML2MueLuParameterTranslator: only \"SA\", \"NSSA\", \"refmaxwell\" and \"Maxwell\" allowed as options for ML default parameters.");
327 Teuchos::ParameterList ML_defaultlist;
328 if (defaultVals == "refmaxwell")
329 SetDefaultsRefMaxwell(ML_defaultlist);
330 else
331 SetDefaults(defaultVals, ML_defaultlist);
332
333 // merge user parameters with default parameters
334 MueLu::MergeParameterList(paramList_in, ML_defaultlist, true);
335 paramList = ML_defaultlist;
336 }
337
338 //
339 // Move smoothers/aggregation/coarse parameters to sublists
340 //
341
342 // ML allows to have level-specific smoothers/aggregation/coarse parameters at the top level of the list or/and defined in sublists:
343 // See also: ML Guide section 6.4.1, MueLu::CreateSublists, ML_CreateSublists
344 ParameterList paramListWithSubList;
345 MueLu::CreateSublists(paramList, paramListWithSubList);
346 paramList = paramListWithSubList; // swap
347 Teuchos::ParameterList adaptingParamList = paramList; // copy of paramList which is used to removed already interpreted parameters
348
349 {
350 // Special handling of ML's aux aggregation
351 //
352 // In ML, when "aggregation: aux: enable" == true, the threshold
353 // is set via "aggregation: aux: threshold" instead of
354 // "aggregation: threshold". In MueLu, we use "aggregation: drop
355 // tol" regardless of "sa: use filtering". So depending on
356 // "aggregation: aux: enable" we use either one or the other
357 // threshold to set "aggregation: drop tol".
358 if (paramListWithSubList.isParameter("aggregation: aux: enable") && paramListWithSubList.get<bool>("aggregation: aux: enable")) {
359 if (paramListWithSubList.isParameter("aggregation: aux: threshold")) {
360 paramListWithSubList.set("aggregation: threshold", paramListWithSubList.get<double>("aggregation: aux: threshold"));
361 paramListWithSubList.remove("aggregation: aux: threshold");
362 }
363 }
364 }
365
366 // stringstream for concatenating xml parameter strings.
367 std::stringstream mueluss;
368 // create surrounding MueLu parameter list
369 mueluss << "<ParameterList name=\"MueLu\">" << std::endl;
370
371 // make sure that MueLu's phase1 matches ML's
372 mueluss << "<Parameter name=\"aggregation: match ML phase1\" type=\"bool\" value=\"true\"/>" << std::endl;
373
374 // make sure that MueLu's phase2a matches ML's
375 mueluss << "<Parameter name=\"aggregation: match ML phase2a\" type=\"bool\" value=\"true\"/>" << std::endl;
376
377 // make sure that MueLu's phase2b matches ML's
378 mueluss << "<Parameter name=\"aggregation: match ML phase2b\" type=\"bool\" value=\"true\"/>" << std::endl;
379
380 // make sure that MueLu's drop tol matches ML's
381 mueluss << "<Parameter name=\"aggregation: use ml scaling of drop tol\" type=\"bool\" value=\"true\"/>" << std::endl;
382
383 // make sure that MueLu's SaP diagonal behavior matches ML's
384 mueluss << "<Parameter name=\"sa: diagonal replacement tolerance\" type=\"double\" value=\"0.0\"/>" << std::endl;
385
386 // We allow MueLu parameter to be passed through the translation.
387 // We split them off and then check if we have conflicts.
388 Teuchos::ParameterList mueluList;
389
390 // loop over all ML parameters in provided parameter list
391 for (ParameterList::ConstIterator param = paramListWithSubList.begin(); param != paramListWithSubList.end(); ++param) {
392 // extract ML parameter name
393 const std::string& pname = paramListWithSubList.name(param);
394
395 // Short circuit the "parameterlist: syntax" parameter
396 // We want to remove this to make sure that createXpetraPreconditioner doesn't re-call translate()
397 if (pname == "parameterlist: syntax") {
398 continue;
399 }
400
401 // extract corresponding (ML) value
402 // remove ParameterList specific information from result string
403 std::stringstream valuess;
404 valuess << paramList.entry(param);
405 std::string valuestr = valuess.str();
406 replaceAll(valuestr, "[unused]", "");
407 replaceAll(valuestr, "[default]", "");
408 valuestr = trim(valuestr);
409
410 // transform ML parameter to corresponding MueLu parameter and generate XML string
411 std::string valueInterpreterStr = "\"" + valuestr + "\"";
412 std::string ret = MasterList::interpretParameterName(MasterList::ML2MueLu(pname), valueInterpreterStr);
413 bool hasBeenProcessed = false;
414
415 if ((pname == "aggregation: aux: enable") && (paramListWithSubList.get<bool>("aggregation: aux: enable"))) {
416 mueluss << "<Parameter name=\"aggregation: drop scheme\" type=\"string\" value=\""
417 << "distance laplacian"
418 << "\"/>" << std::endl;
419 }
420
421 // special handling for verbosity level
422 if (pname == "ML output") {
423 // Translate verbosity parameter
424 int verbosityLevel = std::stoi(valuestr);
425 std::string eVerbLevel = "none";
426 if (verbosityLevel == 0) eVerbLevel = "none";
427 if (verbosityLevel >= 1) eVerbLevel = "low";
428 if (verbosityLevel >= 5) eVerbLevel = "medium";
429 if (verbosityLevel >= 10) eVerbLevel = "high";
430 if (verbosityLevel >= 11) eVerbLevel = "extreme";
431 if (verbosityLevel >= 42) eVerbLevel = "test";
432 if (verbosityLevel >= 666) eVerbLevel = "interfacetest";
433 mueluss << "<Parameter name=\"verbosity\" type=\"string\" value=\"" << eVerbLevel << "\"/>" << std::endl;
434 continue;
435 }
436
437 // add XML string
438 if (ret != "") {
439 mueluss << ret << std::endl;
440
441 // remove parameter from ML parameter list
442 adaptingParamList.remove(pname, false);
443
444 hasBeenProcessed = true;
445 }
446
447 // special handling for energy minimization
448 // TAW: this is not optimal for symmetric problems but at least works.
449 // for symmetric problems the "energy minimization" parameter should not exist anyway...
450 if (pname == "energy minimization: enable") {
451 mueluss << "<Parameter name=\"problem: symmetric\" type=\"bool\" value=\"false\"/>" << std::endl;
452 mueluss << "<Parameter name=\"transpose: use implicit\" type=\"bool\" value=\"false\"/>" << std::endl;
453 hasBeenProcessed = true;
454 }
455
456 // special handling for smoothers
457 if (pname == "smoother: type") {
458 mueluss << GetSmootherFactory(paramList, adaptingParamList, pname, valuestr);
459 hasBeenProcessed = true;
460 }
461
462 // special handling for level-specific smoothers
463 if (pname.find("smoother: list (level", 0) == 0) {
464 // Scan pname (ex: pname="smoother: type (level 2)")
465 std::string type, option;
466 int levelID = -1;
467 {
468 typedef Teuchos::ArrayRCP<char>::size_type size_type;
469 Teuchos::Array<char> ctype(size_type(pname.size() + 1));
470 Teuchos::Array<char> coption(size_type(pname.size() + 1));
471
472 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")
473 type = std::string(ctype.getRawPtr());
474 option = std::string(coption.getRawPtr());
475 option.resize(option.size() - 1); // remove final white-space
476
477 if (matched != 3 || (type != "smoother:")) {
478 TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "MueLu::CreateSublist(), Line " << __LINE__ << ". "
479 << "Error in creating level-specific sublists" << std::endl
480 << "Offending parameter: " << pname << std::endl);
481 }
482
483 mueluss << "<ParameterList name=\"level " << levelID << "\">" << std::endl;
484 mueluss << GetSmootherFactory(paramList.sublist(pname), adaptingParamList.sublist(pname), "smoother: type", paramList.sublist(pname).get<std::string>("smoother: type"));
485 mueluss << "</ParameterList>" << std::endl;
486 }
487 hasBeenProcessed = true;
488 }
489 // special handling for coarse level
490 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.");
491
492 if (pname == "coarse: list") {
493 // interpret smoother/coarse solver data.
494 // Note, that we inspect the "coarse: list" sublist to define the "coarse" smoother/solver
495 // Be aware, that MueLu::CreateSublists renames the prefix of the parameters in the "coarse: list" from "coarse" to "smoother".
496 // Therefore, we have to check the values of the "smoother" parameters
497
498 // DO we have a coarse list / smoother type? If not, assume KLU
499 std::string coarse_smoother = "Amesos-KLU";
500 if (paramList.sublist("coarse: list").isParameter("smoother: type"))
501 coarse_smoother = paramList.sublist("coarse: list").get<std::string>("smoother: type");
502
503 mueluss << GetSmootherFactory(paramList.sublist("coarse: list"), adaptingParamList.sublist("coarse: list"), "coarse: type", coarse_smoother);
504 hasBeenProcessed = true;
505 }
506
507 if (pname == "aggregation: type") {
508 if (valuestr == "Uncoupled" || valuestr == "Uncoupled-MIS") {
509 mueluss << "<Parameter name=\"aggregation: type\" type=\"string\" value=\"uncoupled\"/>" << std::endl;
510 mueluss << "<Parameter name=\"aggregation: backend\" type=\"string\" value=\"host\"/>" << std::endl;
511 } else
512 TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Only \"Uncoupled\" aggregation is supported, not \"" << valuestr << "\"\n");
513 hasBeenProcessed = true;
514 }
515
516 if (pname == "default values" ||
517 pname == "problem: type" ||
518 pname == "smoother: sweeps" ||
519 pname == "smoother: damping factor" ||
520 pname == "smoother: pre or post" ||
521 pname == "smoother: ifpack type" ||
522 pname == "smoother: Chebyshev alpha" ||
523 pname == "smoother: use l1 Gauss-Seidel" ||
524 pname == "smoother: Gauss-Seidel efficient symmetric" ||
525 pname == "smoother: Hiptmair efficient symmetric" ||
526 pname == "subsmoother: node sweeps" ||
527 pname == "subsmoother: edge sweeps" ||
528 pname == "subsmoother: type" ||
529 pname == "subsmoother: Chebyshev alpha" ||
530 pname == "coarse: max size" ||
531 pname == "x-coordinates" ||
532 pname == "y-coordinates" ||
533 pname == "z-coordinates" ||
534 pname == "node: x-coordinates" ||
535 pname == "node: y-coordinates" ||
536 pname == "node: z-coordinates" ||
537 pname == "repartition: partitioner" ||
538 pname == "eigen-analysis: type" ||
539 pname == "increasing or decreasing" // ignored
540 )
541 hasBeenProcessed = true;
542
543 if (paramList.isSublist(pname))
544 hasBeenProcessed = true;
545
546 if (!hasBeenProcessed) {
547 if (MasterList::List()->isParameter(pname)) {
548 mueluList.setEntry(pname, paramList.entry(param));
549 }
550 }
551 } // for
552 mueluss << "</ParameterList>" << std::endl;
553
554 auto translatedList = Teuchos::getParametersFromXmlString(mueluss.str());
555
556 // Check that none of the MueLu parameters that were passed in clash with interpreted ML parameters
557 for (auto it = mueluList.begin(); it != mueluList.end(); ++it) {
558 auto& pname = mueluList.name(it);
559 TEUCHOS_TEST_FOR_EXCEPTION(translatedList->isParameter(pname), MueLu::Exceptions::RuntimeError, "The parameter \"" << pname << "\" has been set both using ML and MueLu parameter names.");
560 }
561 // Add the MueLu parameters to the translated list
562 translatedList->setParameters(mueluList);
563
564 if (defaultVals == "Maxwell") {
565 // ML used a flat list for Maxwell1.
566 // MueLu uses sublists for the two hierarchies.
567 // We need to redistribute the parameters.
568
569 Teuchos::RCP<Teuchos::ParameterList> newList = Teuchos::rcp(new Teuchos::ParameterList());
570
571 // interpret ML list
572 newList->sublist("maxwell1: 22list") = *translatedList;
573
574 // copy verbosity setting
575 if (newList->sublist("maxwell1: 22list").isType<std::string>("verbosity")) {
576 newList->set("verbosity", newList->sublist("maxwell1: 22list").get<std::string>("verbosity"));
577 newList->sublist("maxwell1: 11list").set("verbosity", newList->sublist("maxwell1: 22list").get<std::string>("verbosity"));
578 }
579
580 // Hardwiring options to ensure ML compatibility
581 newList->sublist("maxwell1: 22list").set("use kokkos refactor", false);
582 newList->sublist("maxwell1: 22list").set("tentative: constant column sums", false);
583 newList->sublist("maxwell1: 22list").set("tentative: calculate qr", false);
584
585 newList->sublist("maxwell1: 11list").set("use kokkos refactor", false);
586 newList->sublist("maxwell1: 11list").set("multigrid algorithm", "smoothed reitzinger");
587 newList->sublist("maxwell1: 11list").set("aggregation: type", "uncoupled");
588
589 // We are intentionally setting this to true, contrary to the default value.
590 // This is for backward compatibility with ML.
591 newList->sublist("maxwell1: 11list").set("sa: use edge matrix for smoothing", true);
592
593 // newList->sublist("maxwell1: 11list").set("aggregation: use ml scaling of drop tol", true);
594 newList->sublist("maxwell1: 22list").set("aggregation: use ml scaling of drop tol", true);
595 newList->sublist("maxwell1: 22list").set("aggregation: min agg size", 3);
596
597 // Move damping factor from 22list to 11list
598 if (newList->sublist("maxwell1: 22list").isType<double>("sa: damping factor")) {
599 newList->sublist("maxwell1: 11list").set("sa: damping factor", newList->sublist("maxwell1: 22list").get<double>("sa: damping factor"));
600 newList->sublist("maxwell1: 22list").remove("sa: damping factor");
601 }
602 newList->sublist("maxwell1: 22list").set("multigrid algorithm", "unsmoothed");
603 newList->sublist("maxwell1: 22list").set("aggregation: type", "uncoupled");
604
605 // Move coarse solver and smoother stuff from 22list to 11list
606 std::vector<std::string> convert = {"coarse:", "smoother:", "smoother: pre", "smoother: post"};
607 for (auto it = convert.begin(); it != convert.end(); ++it) {
608 if (newList->sublist("maxwell1: 22list").isType<std::string>(*it + " type")) {
609 newList->sublist("maxwell1: 11list").set(*it + " type", newList->sublist("maxwell1: 22list").get<std::string>(*it + " type"));
610 newList->sublist("maxwell1: 22list").remove(*it + " type");
611 }
612 if (newList->sublist("maxwell1: 22list").isSublist(*it + " params")) {
613 newList->sublist("maxwell1: 11list").set(*it + " params", newList->sublist("maxwell1: 22list").sublist(*it + " params"));
614 newList->sublist("maxwell1: 22list").remove(*it + " params");
615 }
616 }
617 if (newList->sublist("maxwell1: 22list").isType<std::string>("cycle type")) {
618 newList->sublist("maxwell1: 11list").set("cycle type", newList->sublist("maxwell1: 22list").get<std::string>("cycle type"));
619 newList->sublist("maxwell1: 22list").remove("cycle type");
620 }
621 if (newList->sublist("maxwell1: 22list").isType<std::string>("smoother: pre or post")) {
622 newList->sublist("maxwell1: 11list").set("smoother: pre or post", newList->sublist("maxwell1: 22list").get<std::string>("smoother: pre or post"));
623 newList->sublist("maxwell1: 22list").remove("smoother: pre or post");
624 }
625
626 newList->sublist("maxwell1: 22list").set("smoother: type", "none");
627 newList->sublist("maxwell1: 22list").set("coarse: type", "none");
628
629 newList->set("maxwell1: nodal smoother fix zero diagonal threshold", 1e-10);
630 newList->sublist("maxwell1: 22list").set("rap: fix zero diagonals", true);
631 newList->sublist("maxwell1: 22list").set("rap: fix zero diagonals threshold", 1e-10);
632
633 return newList;
634 }
635
636 return translatedList;
637}
638
639static void ML_OverwriteDefaults(ParameterList& inList, ParameterList& List, bool OverWrite) {
640 ParameterList* coarseList = 0;
641 // Don't create the coarse list if it doesn't already exist!
642 if (inList.isSublist("coarse: list"))
643 coarseList = &(inList.sublist("coarse: list"));
644 for (ParameterList::ConstIterator param = List.begin(); param != List.end(); param++) {
645 std::string pname = List.name(param);
646 if (coarseList && pname.find("coarse: ", 0) != std::string::npos) {
647 if (!coarseList->isParameter(pname) || OverWrite)
648 coarseList->setEntry(pname, List.entry(param));
649 } else if (!inList.isParameter(pname) || OverWrite) {
650 inList.setEntry(pname, List.entry(param));
651 }
652 }
653} // ML_OverwriteDefaults()
654
655static int UpdateList(Teuchos::ParameterList& source, Teuchos::ParameterList& dest, bool OverWrite) {
656 for (Teuchos::ParameterList::ConstIterator param = source.begin(); param != source.end(); param++)
657 if (dest.isParameter(source.name(param)) == false || OverWrite)
658 dest.setEntry(source.name(param), source.entry(param));
659 return 0;
660}
661
662int ML2MueLuParameterTranslator::SetDefaults(std::string ProblemType, Teuchos::ParameterList& List,
663 int* ioptions, double* iparams, const bool OverWrite) {
664 Teuchos::RCP<std::vector<int> > options;
665 Teuchos::RCP<std::vector<double> > params;
666
667 // Taken from AztecOO
668 const int MUELU_AZ_OPTIONS_SIZE = 47;
669 const int MUELU_AZ_PARAMS_SIZE = 30;
670
671 /*bool SetDefaults = false;
672 if (ioptions == NULL || iparams == NULL)
673 SetDefaults = true;*/
674
675 if (ioptions == NULL)
676 options = rcp(new std::vector<int>(MUELU_AZ_OPTIONS_SIZE));
677 else
678 options = rcp(new std::vector<int>(ioptions, ioptions + MUELU_AZ_OPTIONS_SIZE));
679 if (iparams == NULL)
680 params = rcp(new std::vector<double>(MUELU_AZ_PARAMS_SIZE));
681 else
682 params = rcp(new std::vector<double>(iparams, iparams + MUELU_AZ_PARAMS_SIZE));
683
684 // if (SetDefaults)
685 // AZ_defaults(&(*options)[0],&(*params)[0]);
686
687 if (ProblemType == "SA") {
688 SetDefaultsSA(List, options, params, OverWrite);
689 } else if (ProblemType == "DD") {
690 SetDefaultsDD(List, options, params, OverWrite);
691 } else if (ProblemType == "DD-ML") {
692 SetDefaultsDD_3Levels(List, options, params, OverWrite);
693 } else if (ProblemType == "maxwell" || ProblemType == "Maxwell") {
694 SetDefaultsMaxwell(List, options, params, OverWrite);
695 } else if (ProblemType == "NSSA") {
696 SetDefaultsNSSA(List, options, params, OverWrite);
697 } else if (ProblemType == "DD-ML-LU") {
698 SetDefaultsDD_3Levels_LU(List, options, params, OverWrite);
699 } else if (ProblemType == "DD-LU") {
700 SetDefaultsDD_LU(List, options, params, OverWrite);
701 } else if (ProblemType == "Classical-AMG") {
702 SetDefaultsClassicalAMG(List, options, params, OverWrite);
703 } else {
704 std::cerr << "ERROR: Wrong input parameter in `SetDefaults' ("
705 << ProblemType << "). Should be: " << std::endl
706 << "ERROR: <SA> / <DD> / <DD-ML> / <maxwell>" << std::endl;
707 }
708 return (0);
709}
710
712 Teuchos::RCP<std::vector<int> >& /* options */,
713 Teuchos::RCP<std::vector<double> >& /* params */,
714 bool OverWrite) {
715 ParameterList List;
716 inList.setName("SA default values");
717 List.set("default values", "SA");
718 List.set("max levels", 10);
719 List.set("prec type", "MGV");
720 List.set("increasing or decreasing", "increasing");
721
722 List.set("aggregation: type", "Uncoupled-MIS");
723 List.set("aggregation: damping factor", 1.333);
724 List.set("eigen-analysis: type", "cg");
725 List.set("eigen-analysis: iterations", 10);
726
727 List.set("smoother: sweeps", 2);
728 List.set("smoother: damping factor", 1.0);
729 List.set("smoother: pre or post", "both");
730 List.set("smoother: type", "symmetric Gauss-Seidel");
731
732 List.set("coarse: type", "Amesos-KLU");
733 List.set("coarse: max size", 128);
734 List.set("coarse: pre or post", "post");
735 List.set("coarse: sweeps", 1);
736 List.set("coarse: split communicator", false);
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::SetDefaultsSA()
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("DD default values");
752 List.set("default values", "DD");
753 List.set("max levels", 2);
754 List.set("prec type", "MGV");
755 List.set("increasing or decreasing", "increasing");
756
757 List.set("aggregation: type", "METIS");
758 List.set("aggregation: local aggregates", 1);
759 List.set("aggregation: damping factor", 1.333);
760 List.set("eigen-analysis: type", "power-method");
761 List.set("eigen-analysis: iterations", 20);
762
763 List.set("smoother: sweeps", 1);
764 List.set("smoother: pre or post", "both");
765 /*#ifdef HAVE_ML_AZTECOO
766 List.set("smoother: type","Aztec");
767 (*options)[AZ_precond] = AZ_dom_decomp;
768 (*options)[AZ_subdomain_solve] = AZ_ilu;
769 List.set("smoother: Aztec options",options);
770 List.set("smoother: Aztec params",params);
771 List.set("smoother: Aztec as solver",false);
772 #endif*/
773
774 List.set("coarse: type", "Amesos-KLU");
775 List.set("coarse: max size", 128);
776 List.set("coarse: pre or post", "post");
777 List.set("coarse: sweeps", 1);
778
779 // Make sure we know this follows the ML defaults
780 List.set("parameterlist: syntax", "ml");
781
782 ML_OverwriteDefaults(inList, List, OverWrite);
783 return 0;
784} // ML2MueLuParameterTranslator::SetDefaultsDD()
785
787 Teuchos::RCP<std::vector<int> >& /*options*/,
788 Teuchos::RCP<std::vector<double> >& /*params*/,
789 bool OverWrite) {
790 ParameterList List;
791
792 inList.setName("DD-ML default values");
793 List.set("default values", "DD-ML");
794
795 List.set("max levels", 3);
796 List.set("prec type", "MGV");
797 List.set("increasing or decreasing", "increasing");
798
799 List.set("aggregation: type", "METIS");
800 List.set("aggregation: nodes per aggregate", 512);
801 List.set("aggregation: next-level aggregates per process", 128);
802 List.set("aggregation: damping factor", 1.333);
803 List.set("eigen-analysis: type", "power-method");
804 List.set("eigen-analysis: iterations", 20);
805
806 List.set("smoother: sweeps", 1);
807 List.set("smoother: pre or post", "both");
808 /*#ifdef HAVE_ML_AZTECOO
809 List.set("smoother: type","Aztec");
810 (*options)[AZ_precond] = AZ_dom_decomp;
811 (*options)[AZ_subdomain_solve] = AZ_ilu;
812 List.set("smoother: Aztec options",options);
813 List.set("smoother: Aztec params",params);
814 List.set("smoother: Aztec as solver",false);
815 #endif*/
816
817 List.set("coarse: type", "Amesos-KLU");
818 List.set("coarse: max size", 128);
819 List.set("coarse: pre or post", "post");
820 List.set("coarse: sweeps", 1);
821
822 // Make sure we know this follows the ML defaults
823 List.set("parameterlist: syntax", "ml");
824
825 ML_OverwriteDefaults(inList, List, OverWrite);
826 return 0;
827} // ML2MueLuParameterTranslator::SetDefaultsDD_3Levels()
828
830 Teuchos::RCP<std::vector<int> >& /* options */,
831 Teuchos::RCP<std::vector<double> >& /* params */,
832 bool OverWrite) {
833 ParameterList List;
834
835 inList.setName("Maxwell default values");
836 List.set("default values", "maxwell");
837 List.set("max levels", 10);
838 List.set("prec type", "MGV");
839 List.set("increasing or decreasing", "decreasing");
840
841 List.set("aggregation: type", "Uncoupled-MIS");
842 List.set("aggregation: damping factor", 1.333);
843 List.set("eigen-analysis: type", "cg");
844 List.set("eigen-analysis: iterations", 10);
845 // dropping threshold for small entries in edge prolongator
846 List.set("aggregation: edge prolongator drop threshold", 0.0);
847
848 List.set("smoother: sweeps", 1);
849 List.set("smoother: damping factor", 1.0);
850 List.set("smoother: pre or post", "both");
851 List.set("smoother: type", "Hiptmair");
852 List.set("smoother: Hiptmair efficient symmetric", true);
853 List.set("subsmoother: type", "Chebyshev"); // Hiptmair subsmoother options
854 List.set("subsmoother: Chebyshev alpha", 20.0);
855 List.set("subsmoother: node sweeps", 4);
856 List.set("subsmoother: edge sweeps", 4);
857
858 // direct solver on coarse problem
859 List.set("coarse: type", "Amesos-KLU");
860 List.set("coarse: max size", 128);
861 List.set("coarse: pre or post", "post");
862 List.set("coarse: sweeps", 1);
863
864 // Make sure we know this follows the ML defaults
865 List.set("parameterlist: syntax", "ml");
866
867 ML_OverwriteDefaults(inList, List, OverWrite);
868 return 0;
869} // ML2MueLuParameterTranslator::SetDefaultsMaxwell()
870
872 Teuchos::RCP<std::vector<int> >& /* options */,
873 Teuchos::RCP<std::vector<double> >& /* params */,
874 bool OverWrite) {
875 ParameterList List;
876
877 inList.setName("NSSA default values");
878 List.set("default values", "NSSA");
879 List.set("max levels", 10);
880 List.set("prec type", "MGW");
881 List.set("increasing or decreasing", "increasing");
882
883 List.set("aggregation: type", "Uncoupled-MIS");
884 List.set("energy minimization: enable", true);
885 List.set("eigen-analysis: type", "power-method");
886 List.set("eigen-analysis: iterations", 20);
887
888 List.set("smoother: sweeps", 4);
889 List.set("smoother: damping factor", .67);
890 List.set("smoother: pre or post", "post");
891 List.set("smoother: type", "symmetric Gauss-Seidel");
892
893 List.set("coarse: type", "Amesos-KLU");
894 List.set("coarse: max size", 256);
895 List.set("coarse: pre or post", "post");
896 List.set("coarse: sweeps", 1);
897
898 // Make sure we know this follows the ML defaults
899 List.set("parameterlist: syntax", "ml");
900
901 ML_OverwriteDefaults(inList, List, OverWrite);
902 return 0;
903} // ML2MueLuParameterTranslator::SetDefaultsNSSA()
904
906 Teuchos::RCP<std::vector<int> >& /*options*/,
907 Teuchos::RCP<std::vector<double> >& /*params*/,
908 bool OverWrite) {
909 ParameterList List;
910
911 inList.setName("DD-LU default values");
912 List.set("default values", "DD-LU");
913 List.set("max levels", 2);
914 List.set("prec type", "MGV");
915 List.set("increasing or decreasing", "increasing");
916
917 List.set("aggregation: type", "METIS");
918 List.set("aggregation: local aggregates", 1);
919 List.set("aggregation: damping factor", 1.333);
920 List.set("eigen-analysis: type", "power-method");
921 List.set("eigen-analysis: iterations", 20);
922
923 List.set("smoother: sweeps", 1);
924 List.set("smoother: pre or post", "both");
925
926 /*#ifdef HAVE_ML_AZTECOO
927 List.set("smoother: type","Aztec");
928 (*options)[AZ_precond] = AZ_dom_decomp;
929 (*options)[AZ_subdomain_solve] = AZ_lu;
930 List.set("smoother: Aztec options",options);
931 List.set("smoother: Aztec params",params);
932 List.set("smoother: Aztec as solver",false);
933 #endif*/
934
935 List.set("coarse: type", "Amesos-KLU");
936 List.set("coarse: max size", 128);
937 List.set("coarse: pre or post", "post");
938 List.set("coarse: sweeps", 1);
939
940 // Make sure we know this follows the ML defaults
941 List.set("parameterlist: syntax", "ml");
942
943 ML_OverwriteDefaults(inList, List, OverWrite);
944 return 0;
945} // ML2MueLuParameterTranslator::SetDefaultsDD_LU()
946
948 Teuchos::RCP<std::vector<int> >& /*options*/,
949 Teuchos::RCP<std::vector<double> >& /*params*/,
950 bool OverWrite) {
951 ParameterList List;
952
953 inList.setName("DD-ML-LU default values");
954 List.set("default values", "DD-ML-LU");
955 List.set("max levels", 3);
956 List.set("prec type", "MGV");
957 List.set("increasing or decreasing", "increasing");
958
959 List.set("aggregation: type", "METIS");
960 List.set("aggregation: nodes per aggregate", 512);
961 List.set("aggregation: next-level aggregates per process", 128);
962 List.set("aggregation: damping factor", 1.333);
963
964 List.set("smoother: sweeps", 1);
965 List.set("smoother: pre or post", "both");
966 /*#ifdef HAVE_ML_AZTECOO
967 List.set("smoother: type","Aztec");
968 (*options)[AZ_precond] = AZ_dom_decomp;
969 (*options)[AZ_subdomain_solve] = AZ_lu;
970 List.set("smoother: Aztec options",options);
971 List.set("smoother: Aztec params",params);
972 List.set("smoother: Aztec as solver",false);
973 #endif*/
974 List.set("coarse: type", "Amesos-KLU");
975 List.set("coarse: max size", 128);
976 List.set("coarse: pre or post", "post");
977 List.set("coarse: sweeps", 1);
978
979 ML_OverwriteDefaults(inList, List, OverWrite);
980 return 0;
981} // ML2MueLuParameterTranslator::SetDefaultsDD_3Levels_LU()
982
984 Teuchos::RCP<std::vector<int> >& /* options */,
985 Teuchos::RCP<std::vector<double> >& /* params */,
986 bool OverWrite) {
987 ParameterList List;
988
989 inList.setName("Classical-AMG default values");
990 List.set("default values", "Classical-AMG");
991 List.set("max levels", 10);
992 List.set("prec type", "MGV");
993 List.set("increasing or decreasing", "increasing");
994 List.set("smoother: sweeps", 2);
995 List.set("smoother: damping factor", 1.0);
996 List.set("smoother: pre or post", "both");
997 List.set("smoother: type", "symmetric Gauss-Seidel");
998
999 List.set("coarse: type", "Amesos-KLU");
1000 List.set("coarse: max size", 128);
1001 List.set("coarse: pre or post", "post");
1002 List.set("coarse: sweeps", 1);
1003
1004 // Make sure we know this follows the ML defaults
1005 List.set("parameterlist: syntax", "ml");
1006
1007 ML_OverwriteDefaults(inList, List, OverWrite);
1008 return 0;
1009} // ML2MueLuParameterTranslator::SetDefaultsClassicalAMG()
1010
1011int ML2MueLuParameterTranslator::SetDefaultsRefMaxwell(Teuchos::ParameterList& inList, bool OverWrite) {
1012 /* Sublists */
1013 Teuchos::ParameterList ListRF, List11, List11c, List22, dummy;
1014 Teuchos::ParameterList& List11_ = inList.sublist("refmaxwell: 11list");
1015 Teuchos::ParameterList& List22_ = inList.sublist("refmaxwell: 22list");
1016 Teuchos::ParameterList& List11c_ = List11_.sublist("edge matrix free: coarse");
1017
1018 /* Build Teuchos List: (1,1) coarse */
1019 SetDefaults("SA", List11c);
1020 List11c.remove("parameterlist: syntax");
1021 List11c.set("cycle applications", 1);
1022 List11c.set("smoother: type", "Chebyshev");
1023 List11c.set("aggregation: threshold", .01);
1024 List11c.set("coarse: type", "Amesos-KLU");
1025 List11c.set("ML label", "coarse (1,1) block");
1026 UpdateList(List11c, List11c_, OverWrite);
1027
1028 /* Build Teuchos List: (1,1) */
1029 SetDefaults("SA", List11);
1030 List11.remove("parameterlist: syntax");
1031 List11.set("cycle applications", 1);
1032 List11.set("aggregation: type", "Uncoupled");
1033 List11.set("smoother: sweeps", 0);
1034 List11.set("aggregation: damping factor", 0.0);
1035 List11.set("edge matrix free: coarse", List11c);
1036 List11.set("aggregation: threshold", .01);
1037 UpdateList(List11, List11_, OverWrite);
1038
1039 /* Build Teuchos List: (2,2) */
1040 SetDefaults("SA", List22);
1041 List22.remove("parameterlist: syntax");
1042 List22.set("cycle applications", 1);
1043 List22.set("smoother: type", "Chebyshev");
1044 List22.set("aggregation: type", "Uncoupled");
1045 List22.set("aggregation: threshold", .01);
1046 List22.set("coarse: type", "Amesos-KLU");
1047 List22.set("ML label", "(2,2) block");
1048
1049 // This line is commented out due to IFPACK issues
1050 // List22.set("smoother: sweeps (level 0)",0);
1051 UpdateList(List22, List22_, OverWrite);
1052
1053 /* Build Teuchos List: Overall */
1054 SetDefaults("maxwell", ListRF, 0, 0, false);
1055 ListRF.set("smoother: type", "Chebyshev");
1056 ListRF.set("smoother: sweeps", 2);
1057 ListRF.set("refmaxwell: 11solver", "edge matrix free"); // either "edge matrix free" or "sa"
1058 ListRF.set("refmaxwell: 11list", List11);
1059 ListRF.set("refmaxwell: 22solver", "multilevel");
1060 ListRF.set("refmaxwell: 22list", List22);
1061 ListRF.set("refmaxwell: mode", "additive");
1062 ListRF.set("default values", "RefMaxwell");
1063 ListRF.set("zero starting solution", false);
1064
1065 // Make sure we know this follows the ML defaults
1066 ListRF.set("parameterlist: syntax", "ml");
1067
1068 UpdateList(ListRF, inList, OverWrite);
1069
1070 return 0;
1071} /*end SetDefaultsRefMaxwell*/
1072
1073} // 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)