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