MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_ML2MueLuParameterTranslator.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef MUELU_ML2MUELUPARAMETERTRANSLATOR_HPP
11 #define MUELU_ML2MUELUPARAMETERTRANSLATOR_HPP
12 
13 #include <functional>
14 #include <vector>
15 #include <cctype>
16 
19 #include <Teuchos_RCP.hpp>
20 
21 #include <MueLu_Exceptions.hpp>
22 #include <MueLu_MasterList.hpp>
24 
25 namespace MueLu {
26 
34  public:
36 
37 
40 
43 
45 
47 
48 
53  static std::string translate(Teuchos::ParameterList& paramList, const std::string& defaultVals = "") {
54  return SetParameterList(paramList, defaultVals);
55  }
56 
61  static std::string translate(const std::string& xmlFileName, const std::string& defaultVals = "") {
62  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(xmlFileName);
63  return SetParameterList(*paramList, defaultVals);
64  }
65 
67 
93  static int SetDefaults(std::string ProblemType, Teuchos::ParameterList& List,
94  int* options = 0, double* params = 0, const bool OverWrite = true);
95 
97  static int SetDefaultsDD(Teuchos::ParameterList& List,
98  Teuchos::RCP<std::vector<int> >& options,
99  Teuchos::RCP<std::vector<double> >& params,
100  bool Overwrite = true);
101 
103  static int SetDefaultsDD_LU(Teuchos::ParameterList& List,
104  Teuchos::RCP<std::vector<int> >& options,
105  Teuchos::RCP<std::vector<double> >& params,
106  bool Overwrite = true);
107 
110  Teuchos::RCP<std::vector<int> >& options,
111  Teuchos::RCP<std::vector<double> >& params,
112  bool Overwrite = true);
113 
116  Teuchos::RCP<std::vector<int> >& options,
117  Teuchos::RCP<std::vector<double> >& params,
118  bool Overwrite = true);
119 
122  Teuchos::RCP<std::vector<int> >& options,
123  Teuchos::RCP<std::vector<double> >& params,
124  bool Overwrite = true);
125 
127  static int SetDefaultsSA(Teuchos::ParameterList& List,
128  Teuchos::RCP<std::vector<int> >& options,
129  Teuchos::RCP<std::vector<double> >& params,
130  bool Overwrite = true);
131 
133  static int SetDefaultsNSSA(Teuchos::ParameterList& List,
134  Teuchos::RCP<std::vector<int> >& options,
135  Teuchos::RCP<std::vector<double> >& params,
136  bool Overwrite = true);
137 
140  Teuchos::RCP<std::vector<int> >& options,
141  Teuchos::RCP<std::vector<double> >& params,
142  bool Overwrite = true);
143 
145  static int SetDefaultsRefMaxwell(Teuchos::ParameterList& inList, bool OverWrite = true);
147 
148  private:
150 
151 
156  static std::string SetParameterList(const Teuchos::ParameterList& paramList_in, const std::string& defaultVals);
157 
164  static std::string GetSmootherFactory(const Teuchos::ParameterList& paramList, Teuchos::ParameterList& adaptingParamList, const std::string& pname, const std::string& value);
165 
167 
168  //
169  // helper routines
170  //
171 
172  // trim from start
173  static inline std::string& ltrim(std::string& s) {
174  s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); }));
175  return s;
176  }
177 
178  // trim from end
179  static inline std::string& rtrim(std::string& s) {
180  s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) { return !std::isspace(c); }).base(), s.end());
181  return s;
182  }
183 
184  // trim from both ends
185  static inline std::string& trim(std::string& s) {
186  return ltrim(rtrim(s));
187  }
188 
190 
191  // std::string xmlString_; ///! string containing MueLu XML parameters corresponding to ML parameters
193 
194 }; // class MLParameterListInterpreter
195 
196 } // end namespace MueLu
197 
198 #endif /* MUELU_ML2MUELUPARAMETERTRANSLATOR_HPP */
static std::string SetParameterList(const Teuchos::ParameterList &paramList_in, const std::string &defaultVals)
: Interpret parameter list
static std::string translate(const std::string &xmlFileName, const std::string &defaultVals="")
: Translate ML parameters to MueLu parameter XML string
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.
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.
Class that accepts ML-style parameters and builds a MueLu parameter list (easy input deck) ...
static int SetDefaultsDD_3Levels(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 3-level domain decomposition preconditioners.
static std::string GetSmootherFactory(const Teuchos::ParameterList &paramList, Teuchos::ParameterList &adaptingParamList, const std::string &pname, const std::string &value)
: Helper function which translates ML smoother/solver paramters to MueLu XML string ...
static int 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. ...
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.
static int SetDefaultsDD(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 2-level domain decomposition preconditioners.
static int SetDefaultsDD_3Levels_LU(Teuchos::ParameterList &List, Teuchos::RCP< std::vector< int > > &options, Teuchos::RCP< std::vector< double > > &params, bool Overwrite=true)
Sets default parameters for aggregation-based 3-level domain decomposition preconditioners with LU...
static int SetDefaultsRefMaxwell(Teuchos::ParameterList &inList, bool OverWrite=true)
Sets defaults for RefMaxwell / Maxwell2.
static std::string translate(Teuchos::ParameterList &paramList, const std::string &defaultVals="")
: Translate ML parameters to MueLu parameter XML string