www.mooseframework.org
InputParameters.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "MooseUtils.h"
14 #include "MooseError.h"
15 #include "MooseTypes.h"
16 #include "MultiMooseEnum.h"
17 #include "ExecFlagEnum.h"
18 #include "Conversion.h"
19 
20 #include "libmesh/parameters.h"
21 
22 #ifdef LIBMESH_HAVE_FPARSER
23 #include "libmesh/fparser.hh"
24 #else
25 template <typename T>
27 {
28 }
29 #endif
30 
31 #include <tuple>
32 #include <unordered_map>
33 #include <mutex>
34 #include <optional>
35 
36 // Forward declarations
37 class Action;
38 class InputParameters;
39 class MooseEnum;
40 class MooseObject;
41 class MultiMooseEnum;
42 class Problem;
43 
48 class InputParameters : public Parameters
49 {
50 public:
51  InputParameters(const InputParameters & rhs);
52  InputParameters(const Parameters & rhs);
53 
54  virtual ~InputParameters() = default;
55 
56  virtual void clear() override;
57 
62  {
64  {
68  };
69 
71  std::vector<std::string> syntax;
74  };
75 
80  void addClassDescription(const std::string & doc_string);
81 
85  std::string getClassDescription() const;
86 
90  virtual void set_attributes(const std::string & name, bool inserted_only) override;
91 
93  bool attemptPrintDeprecated(const std::string & name);
94 
96  template <typename T>
97  void setHelper(const std::string & name);
98 
114  template <typename T>
115  T & set(const std::string & name, bool quiet_mode = false);
116 
128  template <typename T, typename... Ts>
129  void setParameters(const std::string & name, const T & value, Ts... extra_input_parameters);
130 
135  template <typename T, typename UP_T>
136  void rangeCheck(const std::string & full_name,
137  const std::string & short_name,
138  InputParameters::Parameter<T> * param,
139  std::ostream & oss = Moose::out);
140  template <typename T, typename UP_T>
141  void rangeCheck(const std::string & full_name,
142  const std::string & short_name,
143  InputParameters::Parameter<std::vector<T>> * param,
144  std::ostream & oss = Moose::out);
145 
150  template <typename T>
151  T getCheckedPointerParam(const std::string & name, const std::string & error_string = "") const;
152 
158  template <typename T>
159  void addRequiredParam(const std::string & name, const std::string & doc_string);
160 
165  template <typename T>
166  void
167  addRequiredParam(const std::string & name, const T & moose_enum, const std::string & doc_string);
168 
170 
176  template <typename T, typename S>
177  void addParam(const std::string & name, const S & value, const std::string & doc_string);
178  template <typename T>
179  void addParam(const std::string & name, const std::string & doc_string);
181 
185  template <typename T>
186  void addParam(const std::string & name,
187  const std::initializer_list<typename T::value_type> & value,
188  const std::string & doc_string)
189  {
190  addParam<T>(name, T{value}, doc_string);
191  }
192 
194  // BEGIN RANGE CHECKED PARAMETER METHODS
199  template <typename T>
200  void addRequiredRangeCheckedParam(const std::string & name,
201  const std::string & parsed_function,
202  const std::string & doc_string);
203  template <typename T>
204  void addRangeCheckedParam(const std::string & name,
205  const T & value,
206  const std::string & parsed_function,
207  const std::string & doc_string);
208  template <typename T>
209  void addRangeCheckedParam(const std::string & name,
210  const std::string & parsed_function,
211  const std::string & doc_string);
212  // END RANGE CHECKED PARAMETER METHODS
214 
219  template <typename T>
220  void addRequiredCustomTypeParam(const std::string & name,
221  const std::string & custom_type,
222  const std::string & doc_string);
223  template <typename T>
224  void addCustomTypeParam(const std::string & name,
225  const T & value,
226  const std::string & custom_type,
227  const std::string & doc_string);
228  template <typename T>
229  void addCustomTypeParam(const std::string & name,
230  const std::string & custom_type,
231  const std::string & doc_string);
232  template <typename T>
233  void addDeprecatedCustomTypeParam(const std::string & name,
234  const std::string & custom_type,
235  const std::string & doc_string,
236  const std::string & deprecation_msg);
237 
244  template <typename T>
245  void addPrivateParam(const std::string & name, const T & value);
246  template <typename T>
247  void addPrivateParam(const std::string & name);
248 
258  template <typename T>
259  void addRequiredCommandLineParam(const std::string & name,
260  const std::string & syntax,
261  const std::string & doc_string);
262  template <typename T>
263  void addCommandLineParam(const std::string & name,
264  const std::string & syntax,
265  const std::string & doc_string);
266  template <typename T>
267  void addCommandLineParam(const std::string & name,
268  const std::string & syntax,
269  const T & value,
270  const std::string & doc_string);
271 
279  template <typename T>
280  void addDeprecatedParam(const std::string & name,
281  const T & value,
282  const std::string & doc_string,
283  const std::string & deprecation_message);
284 
285  template <typename T>
286  void addDeprecatedParam(const std::string & name,
287  const std::string & doc_string,
288  const std::string & deprecation_message);
289 
299  template <typename T>
300  void checkConsistentType(const std::string & name) const;
301 
305  bool isCommandLineParameter(const std::string & name) const;
306 
310  const std::vector<std::string> & getCommandLineSyntax(const std::string & name) const;
311 
315  CommandLineMetadata::ArgumentType getCommandLineArgumentType(const std::string & name) const;
316 
320  const std::string & getDescription(const std::string & name) const;
321 
327  void addParamNamesToGroup(const std::string & space_delim_names, const std::string group_name);
328 
333  std::string getGroupName(const std::string & param_name) const;
334 
341  template <typename T>
342  void suppressParameter(const std::string & name);
343 
348  template <typename T>
349  void makeParamRequired(const std::string & name);
350 
355  template <typename T>
356  void makeParamNotRequired(const std::string & name);
357 
363  void addCoupledVar(const std::string & name, const std::string & doc_string);
364 
372  void addDeprecatedCoupledVar(const std::string & old_name,
373  const std::string & new_name,
374  const std::string & removal_date = "");
375 
384  void addCoupledVar(const std::string & name, const Real value, const std::string & doc_string);
385 
394  void addCoupledVar(const std::string & name,
395  const std::vector<Real> & value,
396  const std::string & doc_string);
397 
399 
416  void addCoupledVarWithAutoBuild(const std::string & name,
417  const std::string & base_name,
418  const std::string & num_name,
419  const std::string & doc_string);
420  void addRequiredCoupledVarWithAutoBuild(const std::string & name,
421  const std::string & base_name,
422  const std::string & num_name,
423  const std::string & doc_string);
425 
431  std::string getMooseType(const std::string & name) const;
432  std::vector<std::string> getVecMooseType(const std::string & name) const;
433 
443  void addRequiredCoupledVar(const std::string & name, const std::string & doc_string);
444 
448  std::string getDocString(const std::string & name) const;
449 
457  void setDocString(const std::string & name, const std::string & doc);
458 
462  bool isParamRequired(const std::string & name) const;
463 
467  void makeParamNotRequired(const std::string & name);
468 
474  bool isParamValid(const std::string & name) const;
475 
481  bool isParamSetByAddParam(const std::string & name) const;
482 
486  bool isParamDeprecated(const std::string & name) const;
487 
492  bool areAllRequiredParamsValid() const;
493 
497  std::string type(const std::string & name) const;
498 
502  bool isPrivate(const std::string & name) const;
503 
507  void declareControllable(const std::string & name, std::set<ExecFlagType> execute_flags = {});
508 
512  void markControlled(const std::string & name);
513 
517  bool isControllable(const std::string & name) const;
518 
522  const std::set<ExecFlagType> & getControllableExecuteOnTypes(const std::string & name) const;
523 
529  void registerBase(const std::string & value);
530 
542  void registerSystemAttributeName(const std::string & value);
543 
548  const std::string & getSystemAttributeName() const;
549 
557  void registerBuildableTypes(const std::string & names);
558 
574  const std::string & name,
576  Moose::RelationshipManagerInputParameterCallback input_parameter_callback = nullptr);
577 
582 
586  const std::vector<std::string> & getBuildableTypes() const;
587 
591  const std::vector<std::tuple<std::string,
595 
597 
601  void collapseSyntaxNesting(bool collapse);
602  bool collapseSyntaxNesting() const;
604 
606 
610  void mooseObjectSyntaxVisibility(bool visibility);
611  bool mooseObjectSyntaxVisibility() const;
613 
615 
618  using Parameters::operator=;
619  using Parameters::operator+=;
623 
630  void checkParams(const std::string & parsing_syntax);
631 
636  inline std::set<std::string>::const_iterator coupledVarsBegin() const
637  {
638  return _coupled_vars.begin();
639  }
640  inline std::set<std::string>::const_iterator coupledVarsEnd() const
641  {
642  return _coupled_vars.end();
643  }
644 
648  const std::set<std::string> & getCoupledVariableParamNames() const { return _coupled_vars; }
649 
653  const std::unordered_map<std::string, std::string> & getNewToDeprecatedVarMap() const
654  {
656  }
657 
659  bool isRangeChecked(const std::string & param_name) const;
660 
662  std::string rangeCheckedFunction(const std::string & name) const;
663 
665  bool hasDefault(const std::string & param_name) const;
666 
672  bool hasCoupledValue(const std::string & coupling_name) const;
673 
679  bool hasDefaultCoupledValue(const std::string & coupling_name) const;
680 
687  Real defaultCoupledValue(const std::string & coupling_name, unsigned int i = 0) const;
688 
694  unsigned int numberDefaultCoupledValues(const std::string & coupling_name) const;
695 
703  void defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i = 0);
704 
708  std::map<std::string, std::pair<std::string, std::string>> getAutoBuildVectors() const;
709 
710  // BEGIN APPLY PARAMETER METHODS
728  void applyParameters(const InputParameters & common,
729  std::vector<std::string> exclude = std::vector<std::string>());
730 
748  void applySpecificParameters(const InputParameters & common,
749  const std::vector<std::string> & include,
750  bool allow_private = false);
751 
763  void applyParameter(const InputParameters & common,
764  const std::string & common_name,
765  bool allow_private = false);
766  // END APPLY PARAMETER METHODS
767 
778  void applyCoupledVar(const InputParameters & common, const std::string & var_name);
779 
783  bool paramSetByUser(const std::string & name) const;
784 
789  bool isParamSetByUser(const std::string & name) const;
790 
792  /*
793  * These methods are here to retrieve parameters for scalar and vector types respectively. We will
794  * throw errors
795  * when returning most scalar and vector types.
796  */
797  template <typename T>
798  static const T & getParamHelper(const std::string & name,
799  const InputParameters & pars,
800  const T * the_type,
801  const MooseObject * moose_object = nullptr);
803 
804  using Parameters::get;
805 
807  template <typename R1,
808  typename R2,
809  typename V1 = typename std::conditional<std::is_same<R1, MooseEnumItem>::value,
811  std::vector<R1>>::type,
812  typename V2 = typename std::conditional<std::is_same<R2, MooseEnumItem>::value,
814  std::vector<R2>>::type>
815  std::vector<std::pair<R1, R2>> get(const std::string & param1, const std::string & param2) const;
816 
820  std::set<std::string> getParametersList() const;
821 
825  std::set<std::string> getControllableParameters() const;
826 
830  std::set<std::string> getGroupParameters(const std::string & group) const;
831 
836  void setReservedValues(const std::string & name, const std::set<std::string> & reserved);
837 
842  std::set<std::string> reservedValues(const std::string & name) const;
843 
845 
849  std::string & blockLocation() { return _block_location; }
850  const std::string & blockLocation() const { return _block_location; }
852 
854 
858  std::string & blockFullpath() { return _block_fullpath; }
859  const std::string & blockFullpath() const { return _block_fullpath; }
861 
863 
867  const std::string & inputLocation(const std::string & param) const
868  {
869  return at(param)._input_location;
870  }
871  std::string & inputLocation(const std::string & param) { return at(param)._input_location; }
873 
875 
879  const std::string & paramFullpath(const std::string & param) const
880  {
881  return at(param)._param_fullpath;
882  }
883  std::string & paramFullpath(const std::string & param) { return at(param)._param_fullpath; }
885 
887  std::string errorPrefix(const std::string & param) const;
888 
893  std::string & rawParamVal(const std::string & param) { return _params[param]._raw_val; }
894  const std::string & rawParamVal(const std::string & param) const
895  {
896  return _params.at(param)._raw_val;
897  }
898 
903  template <typename T>
904  void ignoreParameter(const std::string & name);
905 
910  bool shouldIgnore(const std::string & name);
911 
915  template <typename T>
916  bool isType(const std::string & name) const;
917 
924  std::string varName(const std::string & var_param_name,
925  const std::string & moose_object_with_var_param_name) const;
926 
934  void renameParam(const std::string & old_name,
935  const std::string & new_name,
936  const std::string & new_docstring);
937 
944  void renameCoupledVar(const std::string & old_name,
945  const std::string & new_name,
946  const std::string & new_docstring);
947 
948  void deprecateParam(const std::string & old_name,
949  const std::string & new_name,
950  const std::string & removal_date);
951 
952  void deprecateCoupledVar(const std::string & old_name,
953  const std::string & new_name,
954  const std::string & removal_date);
955 
962  std::string checkForRename(const std::string & name) const;
963 
970  template <typename T>
971  const T & get(std::string_view name) const;
972 
980  template <typename T>
981  bool have_parameter(std::string_view name) const;
982 
990  template <typename T>
991  void transferParam(const InputParameters & source_param,
992  const std::string & name,
993  const std::string & new_name = "",
994  const std::string & new_description = "");
995 
1008  std::vector<std::string> paramAliases(const std::string & param_name) const;
1009 
1010 private:
1011  // Private constructor so that InputParameters can only be created in certain places.
1012  InputParameters();
1013 
1017  void setParameters() {}
1018 
1022  std::string appendFunctorDescription(const std::string & doc_string) const;
1023 
1027  void setDeprecatedVarDocString(const std::string & new_name, const std::string & doc_string);
1028 
1029  void renameParamInternal(const std::string & old_name,
1030  const std::string & new_name,
1031  const std::string & docstring,
1032  const std::string & removal_date);
1033 
1034  void renameCoupledVarInternal(const std::string & old_name,
1035  const std::string & new_name,
1036  const std::string & docstring,
1037  const std::string & removal_date);
1038 
1039  static void callMooseErrorHelper(const MooseObject & object, const std::string & error);
1040 
1041  struct Metadata
1042  {
1043  std::string _doc_string;
1045  std::string _custom_type;
1047  std::optional<CommandLineMetadata> _cl_data;
1049  std::string _group;
1051  std::string _range_function;
1053  std::pair<std::string, std::string> _autobuild_vecs;
1055  bool _required = false;
1061  bool _valid = false;
1063  bool _is_private = false;
1066  std::vector<Real> _coupled_default = {0};
1068  bool _set_by_add_param = false;
1070  std::set<std::string> _reserved_values;
1074  std::string _input_location;
1076  std::string _param_fullpath;
1078  std::string _raw_val;
1080  bool _controllable = false;
1082  std::set<ExecFlagType> _controllable_flags;
1084  bool _ignore = false;
1085  };
1086 
1087  Metadata & at(const std::string & param_name)
1088  {
1089  const auto param = checkForRename(param_name);
1090  if (_params.count(param) == 0)
1091  mooseError("param '", param, "' not present in InputParams");
1092  return _params[param];
1093  }
1094  const Metadata & at(const std::string & param_name) const
1095  {
1096  const auto param = checkForRename(param_name);
1097  if (_params.count(param) == 0)
1098  mooseError("param '", param, "' not present in InputParams");
1099  return _params.at(param);
1100  }
1101 
1112 
1116  void checkParamName(const std::string & name) const;
1117 
1122  template <typename T, typename S>
1123  void setParamHelper(const std::string & name, T & l_value, const S & r_value);
1124 
1128  const CommandLineMetadata & getCommandLineMetadata(const std::string & name) const;
1129 
1133  template <typename T>
1134  void addCommandLineParamHelper(const std::string & name, const std::string & syntax);
1135 
1137  std::string _block_location;
1138 
1140  std::string _block_fullpath;
1141 
1144  std::map<std::string, Metadata> _params;
1145 
1147  std::set<std::string> _coupled_vars;
1148 
1151  std::string _class_description;
1152 
1155  std::vector<std::string> _buildable_types;
1156 
1161  std::vector<std::tuple<std::string,
1165 
1169 
1172 
1176 
1179 
1181  std::unordered_map<std::string, std::string> _new_to_deprecated_coupled_vars;
1182 
1187  std::map<std::string, std::pair<std::string, std::string>> _old_to_new_name_and_dep;
1188 
1191  std::multimap<std::string, std::string> _new_to_old_names;
1192 
1193  // These are the only objects allowed to _create_ InputParameters
1196  friend class Parser;
1197  // for the printInputFile function in the action warehouse
1198  friend class ActionWarehouse;
1199 };
1200 
1201 template <typename T>
1202 void
1203 InputParameters::setHelper(const std::string & /*name*/)
1204 {
1205 }
1206 
1207 // Template and inline function implementations
1208 template <typename T>
1209 T &
1210 InputParameters::set(const std::string & name_in, bool quiet_mode)
1211 {
1212  const auto name = checkForRename(name_in);
1213 
1215  checkConsistentType<T>(name);
1216 
1217  T & result = this->Parameters::set<T>(name);
1218 
1219  if (quiet_mode)
1220  _params[name]._set_by_add_param = true;
1221 
1222  setHelper<T>(name);
1223 
1224  return result;
1225 }
1226 
1227 template <typename T, typename... Ts>
1228 void
1229 InputParameters::setParameters(const std::string & name,
1230  const T & value,
1231  Ts... extra_input_parameters)
1232 {
1233  this->set<T>(name) = value;
1234  this->setParameters(extra_input_parameters...);
1235 }
1236 
1237 template <typename T, typename UP_T>
1238 void
1239 InputParameters::rangeCheck(const std::string & full_name,
1240  const std::string & short_name,
1241  InputParameters::Parameter<std::vector<T>> * param,
1242  std::ostream & oss)
1243 {
1244  mooseAssert(param, "Parameter is NULL");
1245 
1246  if (!isParamValid(short_name) || _params[short_name]._range_function.empty())
1247  return;
1248 
1261  std::vector<std::string> vars;
1262  if (fp.ParseAndDeduceVariables(_params[short_name]._range_function, vars) != -1) // -1 for success
1263  {
1264  oss << "Error parsing expression: " << _params[short_name]._range_function << '\n';
1265  return;
1266  }
1267 
1268  // Fparser parameter buffer
1269  std::vector<UP_T> parbuf(vars.size());
1270 
1271  // parameter vector
1272  const std::vector<T> & value = param->set();
1273 
1274  // iterate over all vector values (maybe ;)
1275  bool need_to_iterate = false;
1276  unsigned int i = 0;
1277  do
1278  {
1279  // set parameters
1280  for (unsigned int j = 0; j < vars.size(); j++)
1281  {
1282  if (vars[j] == short_name)
1283  {
1284  if (value.size() == 0)
1285  {
1286  oss << "Range checking empty vector: " << _params[short_name]._range_function << '\n';
1287  return;
1288  }
1289 
1290  parbuf[j] = value[i];
1291  need_to_iterate = true;
1292  }
1293  else if (vars[j] == short_name + "_size")
1294  parbuf[j] = value.size();
1295  else
1296  {
1297  if (vars[j].substr(0, short_name.size() + 1) != short_name + "_")
1298  {
1299  oss << "Error parsing expression: " << _params[short_name]._range_function << '\n';
1300  return;
1301  }
1302  std::istringstream iss(vars[j]);
1303  iss.seekg(short_name.size() + 1);
1304 
1305  size_t index;
1306  if (iss >> index && iss.eof())
1307  {
1308  if (index >= value.size())
1309  {
1310  oss << "Error parsing expression: " << _params[short_name]._range_function
1311  << "\nOut of range variable " << vars[j] << '\n';
1312  return;
1313  }
1314  parbuf[j] = value[index];
1315  }
1316  else
1317  {
1318  oss << "Error parsing expression: " << _params[short_name]._range_function
1319  << "\nInvalid variable " << vars[j] << '\n';
1320  return;
1321  }
1322  }
1323  }
1324 
1325  // ensure range-checked input file parameter comparison functions
1326  // do absolute floating point comparisons instead of using a default epsilon.
1327  auto tmp_eps = fp.epsilon();
1328  fp.setEpsilon(0);
1329  UP_T result = fp.Eval(&parbuf[0]);
1330  fp.setEpsilon(tmp_eps);
1331 
1332  // test function using the parameters determined above
1333  if (fp.EvalError())
1334  {
1335  oss << "Error evaluating expression: " << _params[short_name]._range_function << '\n';
1336  return;
1337  }
1338 
1339  if (!result)
1340  {
1341  oss << "Range check failed for parameter " << full_name
1342  << "\n\tExpression: " << _params[short_name]._range_function << "\n";
1343  if (need_to_iterate)
1344  oss << "\t Component: " << i << '\n';
1345  }
1346 
1347  } while (need_to_iterate && ++i < value.size());
1348 }
1349 
1350 template <typename T, typename UP_T>
1351 void
1352 InputParameters::rangeCheck(const std::string & full_name,
1353  const std::string & short_name,
1354  InputParameters::Parameter<T> * param,
1355  std::ostream & oss)
1356 {
1357  mooseAssert(param, "Parameter is NULL");
1358 
1359  if (!isParamValid(short_name) || _params[short_name]._range_function.empty())
1360  return;
1361 
1362  // Parse the expression
1364  if (fp.Parse(_params[short_name]._range_function, short_name) != -1) // -1 for success
1365  {
1366  oss << "Error parsing expression: " << _params[short_name]._range_function << '\n';
1367  return;
1368  }
1369 
1370  // ensure range-checked input file parameter comparison functions
1371  // do absolute floating point comparisons instead of using a default epsilon.
1372  auto tmp_eps = fp.epsilon();
1373  fp.setEpsilon(0);
1374  // We require a non-const value for the implicit upscaling of the parameter type
1375  std::vector<UP_T> value(1, param->set());
1376  UP_T result = fp.Eval(&value[0]);
1377  fp.setEpsilon(tmp_eps);
1378 
1379  if (fp.EvalError())
1380  {
1381  oss << "Error evaluating expression: " << _params[short_name]._range_function
1382  << "\nPerhaps you used the wrong variable name?\n";
1383  return;
1384  }
1385 
1386  if (!result)
1387  oss << "Range check failed for parameter " << full_name
1388  << "\n\tExpression: " << _params[short_name]._range_function << "\n\tValue: " << value[0]
1389  << '\n';
1390 }
1391 
1392 template <typename T>
1393 T
1394 InputParameters::getCheckedPointerParam(const std::string & name_in,
1395  const std::string & error_string) const
1396 {
1397  const auto name = checkForRename(name_in);
1398 
1399  T param = this->get<T>(name);
1400 
1401  // Note: You will receive a compile error on this line if you attempt to pass a non-pointer
1402  // template type to this method
1403  if (param == NULL)
1404  mooseError("Parameter ", name, " is NULL.\n", error_string);
1405  return this->get<T>(name);
1406 }
1407 
1408 template <typename T>
1409 void
1410 InputParameters::addRequiredParam(const std::string & name, const std::string & doc_string)
1411 {
1413  checkConsistentType<T>(name);
1414 
1415  InputParameters::insert<T>(name);
1416  auto & metadata = _params[name];
1417  metadata._required = true;
1418  if (std::is_same_v<T, MooseFunctorName>)
1419  metadata._doc_string = appendFunctorDescription(doc_string);
1420  else
1421  metadata._doc_string = doc_string;
1422 }
1423 
1424 template <typename T>
1425 void
1426 InputParameters::addRequiredParam(const std::string & /*name*/,
1427  const T & /*value*/,
1428  const std::string & /*doc_string*/)
1429 {
1430  mooseError("You cannot call addRequiredParam and supply a default value for this type, please "
1431  "use addParam instead");
1432 }
1433 
1434 template <typename T, typename S>
1435 void
1436 InputParameters::addParam(const std::string & name, const S & value, const std::string & doc_string)
1437 {
1439  checkConsistentType<T>(name);
1440 
1441  T & l_value = InputParameters::set<T>(name);
1442  auto & metadata = _params[name];
1443  if (std::is_same_v<T, MooseFunctorName>)
1444  metadata._doc_string = appendFunctorDescription(doc_string);
1445  else
1446  metadata._doc_string = doc_string;
1447 
1448  // Set the parameter now
1449  setParamHelper(name, l_value, value);
1450 
1451  /* Indicate the default value, as set via addParam, is being used. The parameter is removed from
1452  the list whenever
1453  it changes, see set_attributes */
1454  metadata._set_by_add_param = true;
1455 }
1456 
1457 template <typename T>
1458 void
1459 InputParameters::addParam(const std::string & name, const std::string & doc_string)
1460 {
1462  checkConsistentType<T>(name);
1463 
1464  InputParameters::insert<T>(name);
1465  if (std::is_same_v<T, MooseFunctorName>)
1466  _params[name]._doc_string = appendFunctorDescription(doc_string);
1467  else
1468  _params[name]._doc_string = doc_string;
1469 }
1470 
1471 template <typename T, typename S>
1472 void
1473 InputParameters::setParamHelper(const std::string & /*name*/, T & l_value, const S & r_value)
1474 {
1475  l_value = r_value;
1476 }
1477 
1478 template <typename T>
1479 void
1480 InputParameters::addCommandLineParamHelper(const std::string & name, const std::string & syntax)
1481 {
1482  auto & cl_data = at(name)._cl_data;
1483  cl_data = CommandLineMetadata();
1484  MooseUtils::tokenize(syntax, cl_data->syntax, 1, " \t\n\v\f\r");
1485  if constexpr (std::is_same_v<T, bool>)
1486  cl_data->argument_type = CommandLineMetadata::ArgumentType::NONE;
1487  else if constexpr (std::is_same_v<T, MooseEnum>)
1488  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1489  else
1490  cl_data->argument_type = CommandLineMetadata::ArgumentType::OPTIONAL;
1491 }
1492 
1493 template <typename T>
1494 void
1496  const std::string & parsed_function,
1497  const std::string & doc_string)
1498 {
1499  addRequiredParam<T>(name, doc_string);
1500  _params[name]._range_function = parsed_function;
1501 }
1502 
1503 template <typename T>
1504 void
1505 InputParameters::addRangeCheckedParam(const std::string & name,
1506  const T & value,
1507  const std::string & parsed_function,
1508  const std::string & doc_string)
1509 {
1510  addParam<T>(name, value, doc_string);
1511  _params[name]._range_function = parsed_function;
1512 }
1513 
1514 template <typename T>
1515 void
1516 InputParameters::addRangeCheckedParam(const std::string & name,
1517  const std::string & parsed_function,
1518  const std::string & doc_string)
1519 {
1520  addParam<T>(name, doc_string);
1521  _params[name]._range_function = parsed_function;
1522 }
1523 
1524 template <typename T>
1525 void
1527  const std::string & custom_type,
1528  const std::string & doc_string)
1529 {
1530  addRequiredParam<T>(name, doc_string);
1531  _params[name]._custom_type = custom_type;
1532 }
1533 
1534 template <typename T>
1535 void
1536 InputParameters::addCustomTypeParam(const std::string & name,
1537  const T & value,
1538  const std::string & custom_type,
1539  const std::string & doc_string)
1540 {
1541  addParam<T>(name, value, doc_string);
1542  _params[name]._custom_type = custom_type;
1543 }
1544 
1545 template <typename T>
1546 void
1547 InputParameters::addCustomTypeParam(const std::string & name,
1548  const std::string & custom_type,
1549  const std::string & doc_string)
1550 {
1551  addParam<T>(name, doc_string);
1552  _params[name]._custom_type = custom_type;
1553 }
1554 
1555 template <typename T>
1556 void
1558  const std::string & custom_type,
1559  const std::string & doc_string,
1560  const std::string & deprecation_message)
1561 {
1562  _show_deprecated_message = false;
1563  addParam<T>(name, doc_string);
1564  auto & metadata = _params[name];
1565  metadata._custom_type = custom_type;
1566 
1567  metadata._deprecation_message = deprecation_message;
1568  _show_deprecated_message = true;
1569 }
1570 
1571 template <typename T>
1572 void
1573 InputParameters::addPrivateParam(const std::string & name)
1574 {
1576  checkConsistentType<T>(name);
1577 
1578  InputParameters::insert<T>(name);
1579  _params[name]._is_private = true;
1580 }
1581 
1582 template <typename T>
1583 void
1584 InputParameters::addPrivateParam(const std::string & name, const T & value)
1585 {
1587  checkConsistentType<T>(name);
1588 
1589  InputParameters::set<T>(name) = value;
1590  auto & metadata = _params[name];
1591  metadata._is_private = true;
1592  metadata._set_by_add_param = true;
1593 }
1594 
1595 template <typename T>
1596 void
1598  const std::string & syntax,
1599  const std::string & doc_string)
1600 {
1601  addRequiredParam<T>(name, doc_string);
1602  addCommandLineParamHelper<T>(name, syntax);
1603 }
1604 
1605 template <typename T>
1606 void
1607 InputParameters::addCommandLineParam(const std::string & name,
1608  const std::string & syntax,
1609  const std::string & doc_string)
1610 {
1611  addParam<T>(name, doc_string);
1612  addCommandLineParamHelper<T>(name, syntax);
1613 }
1614 
1615 template <typename T>
1616 void
1617 InputParameters::addCommandLineParam(const std::string & name,
1618  const std::string & syntax,
1619  const T & value,
1620  const std::string & doc_string)
1621 {
1622  addParam<T>(name, value, doc_string);
1623  addCommandLineParamHelper<T>(name, syntax);
1624 }
1625 
1626 template <typename T>
1627 void
1628 InputParameters::checkConsistentType(const std::string & name_in) const
1629 {
1630  const auto name = checkForRename(name_in);
1631 
1632  // If we don't currently have the Parameter, can't be any inconsistency
1633  InputParameters::const_iterator it = _values.find(name);
1634  if (it == _values.end())
1635  return;
1636 
1637  // Now, if we already have the Parameter, but it doesn't have the
1638  // right type, throw an error.
1639  if (!this->Parameters::have_parameter<T>(name))
1640  mooseError("Attempting to set parameter \"",
1641  name,
1642  "\" with type (",
1643  demangle(typeid(T).name()),
1644  ")\nbut the parameter already exists as type (",
1645  it->second->type(),
1646  ")");
1647 }
1648 
1649 template <typename T>
1650 void
1651 InputParameters::suppressParameter(const std::string & name_in)
1652 {
1653  const auto name = checkForRename(name_in);
1654  if (!this->have_parameter<T>(name))
1655  mooseError("Unable to suppress nonexistent parameter: ", name);
1656 
1657  auto & metadata = _params[name];
1658  metadata._required = false;
1659  metadata._is_private = true;
1660  metadata._controllable = false;
1661 }
1662 
1663 template <typename T>
1664 void
1665 InputParameters::ignoreParameter(const std::string & name_in)
1666 {
1667  const auto name = checkForRename(name_in);
1668  suppressParameter<T>(name);
1669  _params[name]._ignore = true;
1670 }
1671 
1672 template <typename T>
1673 void
1674 InputParameters::makeParamRequired(const std::string & name_in)
1675 {
1676  const auto name = checkForRename(name_in);
1677 
1678  if (!this->have_parameter<T>(name))
1679  mooseError("Unable to require nonexistent parameter: ", name);
1680 
1681  _params[name]._required = true;
1682 }
1683 
1684 template <typename T>
1685 void
1686 InputParameters::makeParamNotRequired(const std::string & name_in)
1687 {
1688  const auto name = checkForRename(name_in);
1689 
1690  if (!this->have_parameter<T>(name))
1691  mooseError("Unable to un-require nonexistent parameter: ", name);
1692 
1693  _params[name]._required = false;
1694 }
1695 
1696 template <typename T>
1697 void
1698 InputParameters::addDeprecatedParam(const std::string & name,
1699  const T & value,
1700  const std::string & doc_string,
1701  const std::string & deprecation_message)
1702 {
1703  _show_deprecated_message = false;
1704  addParam<T>(name, value, doc_string);
1705 
1706  _params[name]._deprecation_message = deprecation_message;
1707  _show_deprecated_message = true;
1708 }
1709 
1710 template <typename T>
1711 void
1712 InputParameters::addDeprecatedParam(const std::string & name,
1713  const std::string & doc_string,
1714  const std::string & deprecation_message)
1715 {
1716  _show_deprecated_message = false;
1717  addParam<T>(name, doc_string);
1718 
1719  _params[name]._deprecation_message = deprecation_message;
1720  _show_deprecated_message = true;
1721 }
1722 
1723 // Forward declare MooseEnum specializations for add*Param
1724 template <>
1725 void InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
1726  const MooseEnum & moose_enum,
1727  const std::string & doc_string);
1728 
1729 template <>
1730 void InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1731  const MultiMooseEnum & moose_enum,
1732  const std::string & doc_string);
1733 
1734 template <>
1735 void InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1736  const std::string & name,
1737  const std::vector<MooseEnum> & moose_enums,
1738  const std::string & doc_string);
1739 
1740 template <>
1741 void InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1742  const std::string & /*doc_string*/);
1743 
1744 template <>
1745 void InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1746  const std::string & /*doc_string*/);
1747 
1748 template <>
1749 void InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1750  const std::string & /*doc_string*/);
1751 
1752 template <>
1753 void InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/);
1754 
1755 template <>
1756 void InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/);
1757 
1758 template <>
1759 void InputParameters::addDeprecatedParam<MooseEnum>(const std::string & name,
1760  const std::string & doc_string,
1761  const std::string & deprecation_message);
1762 
1763 template <>
1764 void InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & name,
1765  const std::string & doc_string,
1766  const std::string & deprecation_message);
1767 
1768 template <>
1769 void InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1770  const std::string & name,
1771  const std::string & doc_string,
1772  const std::string & deprecation_message);
1773 
1774 // Forward declare specializations for setParamHelper
1775 template <>
1776 void InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & name,
1777  PostprocessorName & l_value,
1778  const Real & r_value);
1779 
1780 template <>
1781 void InputParameters::setParamHelper<PostprocessorName, int>(const std::string & name,
1782  PostprocessorName & l_value,
1783  const int & r_value);
1784 
1785 template <>
1786 void InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1787  FunctionName & l_value,
1788  const Real & r_value);
1789 
1790 template <>
1791 void InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1792  FunctionName & l_value,
1793  const int & r_value);
1794 
1795 template <>
1796 void InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1797  MaterialPropertyName & l_value,
1798  const Real & r_value);
1799 
1800 template <>
1801 void InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1802  MaterialPropertyName & l_value,
1803  const int & r_value);
1804 
1805 template <>
1806 void InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
1807  MooseFunctorName & l_value,
1808  const Real & r_value);
1809 
1810 template <>
1811 void InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
1812  MooseFunctorName & l_value,
1813  const int & r_value);
1814 
1815 template <typename T>
1816 const T &
1817 InputParameters::getParamHelper(const std::string & name_in,
1818  const InputParameters & pars,
1819  const T *,
1820  const MooseObject * moose_object /* = nullptr */)
1821 {
1822  const auto name = pars.checkForRename(name_in);
1823 
1824  if (!pars.isParamValid(name))
1825  {
1826  std::stringstream err;
1827  err << "The parameter \"" << name << "\" is being retrieved before being set.";
1828  if (moose_object)
1829  callMooseErrorHelper(*moose_object, err.str());
1830  else
1831  mooseError(err.str());
1832  }
1833 
1834  return pars.get<T>(name);
1835 }
1836 
1837 // Declare specializations so we don't fall back on the generic
1838 // implementation, but the definition will be in InputParameters.C so
1839 // we won't need to bring in *MooseEnum header files here.
1840 template <>
1841 const MooseEnum &
1842 InputParameters::getParamHelper<MooseEnum>(const std::string & name,
1843  const InputParameters & pars,
1844  const MooseEnum *,
1845  const MooseObject * moose_object /* = nullptr */);
1846 
1847 template <>
1848 const MultiMooseEnum &
1849 InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name,
1850  const InputParameters & pars,
1851  const MultiMooseEnum *,
1852  const MooseObject * moose_object /* = nullptr */);
1853 
1854 template <typename R1, typename R2, typename V1, typename V2>
1855 std::vector<std::pair<R1, R2>>
1856 InputParameters::get(const std::string & param1_in, const std::string & param2_in) const
1857 {
1858  const auto param1 = checkForRename(param1_in);
1859  const auto param2 = checkForRename(param2_in);
1860 
1861  const auto & v1 = get<V1>(param1);
1862  const auto & v2 = get<V2>(param2);
1863 
1864  auto controllable = getControllableParameters();
1865  if (controllable.count(param1) || controllable.count(param2))
1866  mooseError(errorPrefix(param1),
1867  " and/or ",
1868  errorPrefix(param2) +
1869  " are controllable parameters and cannot be retireved using "
1870  "the MooseObject::getParam/InputParameters::get methods for pairs");
1871 
1872  if (v1.size() != v2.size())
1873  mooseError("Vector parameters ",
1874  errorPrefix(param1),
1875  "(size: ",
1876  v1.size(),
1877  ") and " + errorPrefix(param2),
1878  "(size: ",
1879  v2.size(),
1880  ") are of different lengths \n");
1881 
1882  std::vector<std::pair<R1, R2>> parameter_pairs;
1883  auto i1 = v1.begin();
1884  auto i2 = v2.begin();
1885  for (; i1 != v1.end() && i2 != v2.end(); ++i1, ++i2)
1886  parameter_pairs.emplace_back(std::make_pair(*i1, *i2));
1887  return parameter_pairs;
1888 }
1889 
1891 
1892 template <typename T>
1893 bool
1894 InputParameters::isType(const std::string & name_in) const
1895 {
1896  const auto name = checkForRename(name_in);
1897 
1898  if (!_params.count(name))
1899  mooseError("Parameter \"", name, "\" is not valid.");
1900  return have_parameter<T>(name);
1901 }
1902 
1903 template <typename T>
1904 const T &
1905 InputParameters::get(std::string_view name_in) const
1906 {
1907  const auto name = checkForRename(std::string(name_in));
1908 
1909  return Parameters::get<T>(name);
1910 }
1911 
1912 template <typename T>
1913 bool
1914 InputParameters::have_parameter(std::string_view name_in) const
1915 {
1916  const auto name = checkForRename(std::string(name_in));
1917 
1918  return Parameters::have_parameter<T>(name);
1919 }
1920 
1921 template <typename T>
1922 void
1924  const std::string & name_in,
1925  const std::string & new_name,
1926  const std::string & new_description)
1927 {
1928  const auto name = source_params.checkForRename(std::string(name_in));
1929  const auto p_name = new_name.empty() ? name_in : new_name;
1930  if (!source_params.have_parameter<T>(name) && !source_params.hasCoupledValue(name))
1931  mooseError("The '",
1932  name_in,
1933  "' parameter could not be transferred because it does not exist with type '",
1934  MooseUtils::prettyCppType<T>(),
1935  "' in the source parameters");
1936  if (name != name_in)
1937  mooseWarning("The transferred parameter " + name_in + " is deprecated in favor of " + name +
1938  " in the source parameters. The new name should likely be used for the parameter "
1939  "transfer instead.");
1940  const std::string description =
1941  new_description.empty() ? source_params.getDescription(name) : new_description;
1942 
1943  if (source_params.isParamRequired(name))
1944  {
1945  // Check for a variable parameter
1946  if (source_params.hasCoupledValue(name))
1947  addRequiredCoupledVar(p_name, description);
1948  // Enums parameters have a default list of options
1949  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
1950  addRequiredParam<T>(p_name, source_params.get<T>(name), description);
1951  else if (source_params.isRangeChecked(name))
1952  addRequiredRangeCheckedParam<T>(
1953  p_name, source_params.rangeCheckedFunction(name), description);
1954  else
1955  addRequiredParam<T>(p_name, description);
1956  }
1957  else
1958  {
1959  // Check for a variable parameter
1960  if (source_params.hasCoupledValue(name))
1961  {
1962  if (!source_params.hasDefaultCoupledValue(name))
1963  addCoupledVar(p_name, description);
1964  else if (source_params.numberDefaultCoupledValues(name) == 1)
1965  addCoupledVar(p_name, source_params.defaultCoupledValue(name), description);
1966  else
1967  {
1968  std::vector<Real> coupled_values;
1969  for (const auto i : make_range(source_params.numberDefaultCoupledValues(name)))
1970  coupled_values.push_back(source_params.defaultCoupledValue(name, i));
1971  addCoupledVar(p_name, coupled_values, description);
1972  }
1973  }
1974  else if (source_params.isRangeChecked(name))
1975  {
1976  if (source_params.hasDefault(name))
1977  addRangeCheckedParam<T>(p_name,
1978  source_params.get<T>(name),
1979  source_params.rangeCheckedFunction(name),
1980  description);
1981  else
1982  addRangeCheckedParam<T>(p_name, source_params.rangeCheckedFunction(name), description);
1983  }
1984  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
1985  addParam<T>(p_name, source_params.get<T>(name), description);
1986  else
1987  {
1988  if (source_params.hasDefault(name))
1989  addParam<T>(p_name, source_params.get<T>(name), description);
1990  else
1991  addParam<T>(p_name, description);
1992  }
1993  }
1994 
1995  // Copy other attributes
1996  if (source_params.isPrivate(name))
1997  _params[p_name]._is_private = true;
1998  if (source_params.isControllable(name))
1999  _params[p_name]._controllable = true;
2000 }
std::multimap< std::string, std::string > _new_to_old_names
A map from derived-class/blessed parameter names to associated base-class/deprecated parameter names...
std::string name(const ElemQuality q)
OStreamProxy err
std::vector< std::string > syntax
The syntax for the parameter (i.e., ["-t", "--timing"])
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
bool isRangeChecked(const std::string &param_name) const
Return whether a parameter has a range check.
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a parameter and provide a new documentation string.
void setParameters()
Method to terminate the recursive setParameters definition.
void clearRelationshipManagers()
Clears all currently registered RelationshipManagers.
std::string _input_location
original location of parameter (i.e. filename,linenum) - used for nice error messages.
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
bool hasCoupledValue(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
std::string _raw_val
raw token text for a parameter - usually only set for filepath type params.
Storage container for all InputParamter objects.
bool _allow_copy
A flag for toggling the error message in the copy constructor.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:779
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
RelationshipManagerType
Main types of Relationship Managers.
Definition: MooseTypes.h:876
std::string & rawParamVal(const std::string &param)
Get/set a string representing the raw, unmodified token text for the given param. ...
InputParameters & operator=(const InputParameters &rhs)
std::map< std::string, std::pair< std::string, std::string > > getAutoBuildVectors() const
Returns the auto build vectors for all parameters.
std::string _custom_type
The custom type that will be printed in the YAML dump for a parameter if supplied.
std::set< std::string > getParametersList() const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Enable support for initializer lists as default arguments for container type.
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
Method for applying common parameters.
void setDocString(const std::string &name, const std::string &doc)
Set the doc string of a parameter.
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
bool isParamDeprecated(const std::string &name) const
Returns True if the parameters is deprecated.
const std::vector< std::tuple< std::string, Moose::RelationshipManagerType, Moose::RelationshipManagerInputParameterCallback > > & getBuildableRelationshipManagerTypes() const
Returns the list of buildable (or required) RelationshipManager object types for this object...
const std::vector< std::string > & getCommandLineSyntax(const std::string &name) const
CommandLineMetadata::ArgumentType getCommandLineArgumentType(const std::string &name) const
bool isControllable(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is controllable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
std::string _block_location
original location of input block (i.e. filename,linenum) - used for nice error messages.
std::set< ExecFlagType > _controllable_flags
Controllable execute flag restriction.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:296
std::unordered_map< std::string, std::string > _new_to_deprecated_coupled_vars
A map from deprecated coupled variable names to the new blessed name.
std::string _block_fullpath
full HIT path of the block from the input file - used for nice error messages.
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
const std::vector< std::string > & getBuildableTypes() const
Returns the list of buildable types as a std::vector<std::string>
void addCustomTypeParam(const std::string &name, const T &value, const std::string &custom_type, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Class that hold the whole problem being solved.
Definition: Problem.h:19
void setDeprecatedVarDocString(const std::string &new_name, const std::string &doc_string)
Private method for setting deprecated coupled variable documentation strings.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
InputParameters & operator+=(const InputParameters &rhs)
const std::set< std::string > & getCoupledVariableParamNames() const
Return the coupled variable parameter names.
ArgumentType argument_type
The type of argument.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
bool _ignore
whether user setting of this parameter should be ignored
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void renameCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a coupled variable and provide a new documentation string.
std::set< std::string >::const_iterator coupledVarsBegin() const
Methods returning iterators to the coupled variables names stored in this InputParameters object...
std::string & paramFullpath(const std::string &param)
void applyCoupledVar(const InputParameters &common, const std::string &var_name)
Apply properties of a single coupled variable in common, to a single coupled variable stored in this ...
friend InputParameters emptyInputParameters()
void registerBuildableTypes(const std::string &names)
This method is here to indicate which Moose types a particular Action may build.
bool attemptPrintDeprecated(const std::string &name)
Prints the deprecated parameter message, assuming we have the right flags set.
const std::unordered_map< std::string, std::string > & getNewToDeprecatedVarMap() const
Return the new to deprecated variable name map.
bool isPrivate(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is private or not.
void checkConsistentType(const std::string &name) const
This method checks to make sure that we aren&#39;t adding a parameter with the same name but a different ...
std::vector< std::string > paramAliases(const std::string &param_name) const
Return all the aliased names associated with param_name.
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
std::set< std::string > _reserved_values
The reserved option names for a parameter.
void addRequiredCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
Add parameters for retrieval from the command line.
Base class for actions.
Definition: Action.h:38
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
InputParameters emptyInputParameters()
void checkParamName(const std::string &name) const
Make sure the parameter name doesn&#39;t have any invalid characters.
void renameParamInternal(const std::string &old_name, const std::string &new_name, const std::string &docstring, const std::string &removal_date)
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
bool mooseObjectSyntaxVisibility() const
unsigned int numberDefaultCoupledValues(const std::string &coupling_name) const
Get the number of defaulted coupled value entries.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
MPI_Status status
const std::string & getDescription(const std::string &name) const
Get the documentation string for a parameter.
std::string _param_fullpath
full HIT path of the parameter from the input file - used for nice error messages.
Structure for storing information about a command line parameter.
bool isParamSetByAddParam(const std::string &name) const
Returns whether or not the parameter was set due to addParam.
bool _show_deprecated_message
Flag for disabling deprecated parameters message, this is used by applyParameters to avoid dumping me...
void ignoreParameter(const std::string &name)
Informs this object that values for this parameter set from the input file or from the command line s...
bool _required
True for parameters that are required (i.e. will cause an abort if not supplied)
std::string _range_function
The map of functions used for range checked parameters.
bool _collapse_nesting
This parameter collapses one level of nesting in the syntax blocks.
std::string getDocString(const std::string &name) const
Returns the documentation string for the specified parameter name.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void deprecateParam(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
std::set< std::string >::const_iterator coupledVarsEnd() const
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
const std::string & rawParamVal(const std::string &param) const
bool shouldIgnore(const std::string &name)
Whether to ignore the value of an input parameter set in the input file or from the command line...
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
The type for the callback to set RelationshipManager parameters.
Definition: MooseTypes.h:902
bool hasDefaultCoupledValue(const std::string &coupling_name) const
Return whether or not the requested parameter has a default coupled value.
void setHelper(const std::string &name)
This functions is called in set as a &#39;callback&#39; to avoid code duplication.
void markControlled(const std::string &name)
Marker a parameter that has been changed by the Control system (this is for output purposes) ...
bool areAllRequiredParamsValid() const
This method returns true if all of the parameters in this object are valid (i.e.
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
const std::string & inputLocation(const std::string &param) const
Get/set a string representing the location in the input text the parameter originated from (i...
void addDeprecatedCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date="")
This method adds a deprecated coupled variable name pair.
std::string _class_description
The class description for the owning object.
const std::set< ExecFlagType > & getControllableExecuteOnTypes(const std::string &name) const
Return the allowed execute flags for a controllable parameter.
void renameCoupledVarInternal(const std::string &old_name, const std::string &new_name, const std::string &docstring, const std::string &removal_date)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
std::string appendFunctorDescription(const std::string &doc_string) const
Appends description of what a functor is to a doc string.
void addCommandLineParamHelper(const std::string &name, const std::string &syntax)
Helper for all of the addCommandLineParam() calls, which sets up _cl_data in the metadata.
void checkParams(const std::string &parsing_syntax)
This function checks parameters stored in the object to make sure they are in the correct state as th...
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false)
Apply values from a single parameter in common, to a single parameter stored in this object...
std::string demangle(const char *name)
void applyParameters(const InputParameters &common, std::vector< std::string > exclude=std::vector< std::string >())
Method for applying common parameters.
void transferParam(const InputParameters &source_param, const std::string &name, const std::string &new_name="", const std::string &new_description="")
A routine to transfer a parameter from one class&#39; validParams to another.
static void callMooseErrorHelper(const MooseObject &object, const std::string &error)
std::set< std::string > reservedValues(const std::string &name) const
Get a set of reserved parameter values.
static const T & getParamHelper(const std::string &name, const InputParameters &pars, const T *the_type, const MooseObject *moose_object=nullptr)
void rangeCheck(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, std::ostream &oss=Moose::out)
Runs a range on the supplied parameter if it exists and throws an error if that check fails...
std::vector< Real > _coupled_default
The default value for optionally coupled variables.
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
void setReservedValues(const std::string &name, const std::set< std::string > &reserved)
Provide a set of reserved values for a parameter.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
void makeParamNotRequired(const std::string &name)
Changes the parameter to not be required.
void allowCopy(bool status)
Toggle the availability of the copy constructor.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
std::string _deprecation_message
If non-empty, this parameter is deprecated.
void addCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
const std::string & blockFullpath() const
std::string varName(const std::string &var_param_name, const std::string &moose_object_with_var_param_name) const
Determine the actual variable name from the given variable parameter name.
bool isType(const std::string &name) const
void addDeprecatedCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string, const std::string &deprecation_msg)
bool _is_private
The set of parameters that will NOT appear in the the dump of the parser tree.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::set< std::string > _coupled_vars
The coupled variables set.
std::vector< std::tuple< std::string, Moose::RelationshipManagerType, Moose::RelationshipManagerInputParameterCallback > > _buildable_rm_types
The RelationshipManagers that this object may either build or require.
void addRequiredCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
void addCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
These methods add a coupled variable name pair.
std::string & blockFullpath()
Get/set a string representing the full HIT parameter path from the input file (e.g.
virtual ~InputParameters()=default
std::string getGroupName(const std::string &param_name) const
This method retrieves the group name for the passed parameter name if one exists. ...
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
IntRange< T > make_range(T beg, T end)
bool isCommandLineParameter(const std::string &name) const
std::pair< std::string, std::string > _autobuild_vecs
directions for auto build vectors (base_, 5) -> "base_0 base_1 base_2 base_3 base_4") ...
bool paramSetByUser(const std::string &name) const
Deprecated method.
void makeParamRequired(const std::string &name)
Changes the parameter to be required.
bool _valid
Whether the parameter is either explicitly set or provided a default value when added Note: We do not...
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
These methods add an option parameter and with a customer type to the InputParameters object...
bool isParamRequired(const std::string &name) const
Returns a boolean indicating whether the specified parameter is required or not.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
const std::string & getSystemAttributeName() const
Get the system attribute name if it was registered.
const CommandLineMetadata & getCommandLineMetadata(const std::string &name) const
std::vector< std::string > _buildable_types
The parameter is used to restrict types that can be built.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
const std::string & blockLocation() const
bool _moose_object_syntax_visibility
This parameter hides derived MOOSE object types from appearing in syntax dumps.
virtual void clear() override
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
bool hasDefault(const std::string &param_name) const
Return whether a parameter has a default.
bool _controllable
True if the parameters is controllable.
std::map< std::string, Metadata > _params
The actual parameter data.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual void set_attributes(const std::string &name, bool inserted_only) override
Override from libMesh to set user-defined attributes on our parameter.
std::string errorPrefix(const std::string &param) const
generate error message prefix with parameter name and location (if available)
std::string getClassDescription() const
Returns the class description.
bool _set_by_add_param
True if a parameters value was set by addParam, and not set again.
std::map< std::string, std::pair< std::string, std::string > > _old_to_new_name_and_dep
A map from base-class/deprecated parameter names to derived-class/blessed parameter names and the dep...
std::set< std::string > getControllableParameters() const
Return list of controllable parameters.
void setParamHelper(const std::string &name, T &l_value, const S &r_value)
This method is called when adding a Parameter with a default value, can be specialized for non-matchi...
std::vector< std::string > getVecMooseType(const std::string &name) const
std::optional< CommandLineMetadata > _cl_data
The data pertaining to a command line parameter (empty if not a command line param) ...
const Metadata & at(const std::string &param_name) const
Metadata & at(const std::string &param_name)
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
std::string rangeCheckedFunction(const std::string &name) const
Return the range check function for any parameter (empty string if it is not range checked) ...
bool collapseSyntaxNesting() const
std::string & blockLocation()
Get/set a string representing the location (i.e.
Class for parsing input files.
Definition: Parser.h:112
std::string _group
The names of the parameters organized into groups.
const std::string & paramFullpath(const std::string &param) const
Get/set a string representing the full HIT parameter path from the input file (e.g.
ExecFlagEnum execute_flags
Storage for the registered execute flags.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
std::set< std::string > getGroupParameters(const std::string &group) const
Return names of parameters within a group.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
std::string & inputLocation(const std::string &param)