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