https://mooseframework.inl.gov
InputParameters.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "MooseEnum.h"
17 #include "MultiMooseEnum.h"
18 #include "ExecFlagEnum.h"
19 #include "Conversion.h"
20 #include "DataFileUtils.h"
21 #include "MoosePassKey.h"
22 
23 #include "libmesh/parameters.h"
24 
25 #ifdef LIBMESH_HAVE_FPARSER
26 #include "libmesh/fparser.hh"
27 #else
28 template <typename T>
30 {
31 }
32 #endif
33 
34 #include <tuple>
35 #include <unordered_map>
36 #include <mutex>
37 #include <optional>
38 #include <filesystem>
39 #include <regex>
40 
41 #include <gtest/gtest.h>
42 
43 // Forward declarations
44 class Action;
45 class ActionFactory;
46 class Factory;
47 class FEProblemBase;
48 class InputParameters;
49 class MooseEnum;
50 class MooseObject;
51 class MultiMooseEnum;
52 class Problem;
53 namespace hit
54 {
55 class Node;
56 }
57 namespace Moose
58 {
59 class Builder;
60 }
61 class CommandLine;
62 
68 {
69 public:
70  InputParameters(const InputParameters & rhs);
71  InputParameters(const Parameters & rhs);
72 
73  virtual ~InputParameters() = default;
74 
75  virtual void clear() override;
76 
81  {
83  {
87  };
88 
90  std::string syntax;
92  std::vector<std::string> switches;
96  bool required;
98  bool set_by_command_line = false;
100  bool global = false;
101  };
102 
108  {
109  friend class Action;
110  friend class ActionFactory;
111  friend class Moose::Builder;
112  friend class Factory;
113  friend class FEProblemBase;
114  friend class InputParameters;
115  FRIEND_TEST(InputParametersTest, fileNames);
118  };
119 
125  {
126  friend class Moose::Builder;
127  FRIEND_TEST(InputParametersTest, fileNames);
130  };
131 
139  template <typename T>
141  {
142  static constexpr bool value =
143  std::is_same_v<T, std::string> || std::is_same_v<T, std::vector<std::string>> ||
144  std::is_same_v<T, Real> || std::is_same_v<T, unsigned int> || std::is_same_v<T, int> ||
145  std::is_same_v<T, bool> || std::is_same_v<T, MooseEnum>;
146  };
147 
152  void addClassDescription(const std::string & doc_string);
153 
157  std::string getClassDescription() const;
158 
162  virtual void set_attributes(const std::string & name, bool inserted_only) override;
163 
167  std::optional<std::string> queryDeprecatedParamMessage(const std::string & name) const;
168 
170  template <typename T>
171  void setHelper(const std::string & name);
172 
188  template <typename T>
189  T & set(const std::string & name, bool quiet_mode = false);
190 
202  template <typename T, typename... Ts>
203  void setParameters(const std::string & name, const T & value, Ts... extra_input_parameters);
204 
212  template <typename T, typename UP_T>
214  std::optional<std::pair<bool, std::string>>
215  rangeCheck(const std::string & full_name,
216  const std::string & short_name,
217  const InputParameters::Parameter<T> & param,
218  const bool include_param_path = true);
219  template <typename T, typename UP_T>
220  std::optional<std::pair<bool, std::string>>
221  rangeCheck(const std::string & full_name,
222  const std::string & short_name,
223  const InputParameters::Parameter<std::vector<T>> & param,
224  const bool include_param_path = true);
226 
230  template <typename T>
231  T getCheckedPointerParam(const std::string & name, const std::string & error_string = "") const;
232 
238  template <typename T>
239  void addRequiredParam(const std::string & name, const std::string & doc_string);
240 
245  template <typename T>
246  void
247  addRequiredParam(const std::string & name, const T & moose_enum, const std::string & doc_string);
248 
250 
256  template <typename T, typename S>
257  void addParam(const std::string & name, const S & value, const std::string & doc_string);
258  template <typename T>
259  void addParam(const std::string & name, const std::string & doc_string);
261 
265  template <typename T>
266  void addParam(const std::string & name,
267  const std::initializer_list<typename T::value_type> & value,
268  const std::string & doc_string)
269  {
270  addParam<T>(name, T{value}, doc_string);
271  }
272 
274  // BEGIN RANGE CHECKED PARAMETER METHODS
279  template <typename T>
280  void addRequiredRangeCheckedParam(const std::string & name,
281  const std::string & parsed_function,
282  const std::string & doc_string);
283  template <typename T>
284  void addRangeCheckedParam(const std::string & name,
285  const T & value,
286  const std::string & parsed_function,
287  const std::string & doc_string);
288  template <typename T>
289  void addRangeCheckedParam(const std::string & name,
290  const std::string & parsed_function,
291  const std::string & doc_string);
292  // END RANGE CHECKED PARAMETER METHODS
294 
299  template <typename T>
300  void addRequiredCustomTypeParam(const std::string & name,
301  const std::string & custom_type,
302  const std::string & doc_string);
303  template <typename T>
304  void addCustomTypeParam(const std::string & name,
305  const T & value,
306  const std::string & custom_type,
307  const std::string & doc_string);
308  template <typename T>
309  void addCustomTypeParam(const std::string & name,
310  const std::string & custom_type,
311  const std::string & doc_string);
312  template <typename T>
313  void addDeprecatedCustomTypeParam(const std::string & name,
314  const std::string & custom_type,
315  const std::string & doc_string,
316  const std::string & deprecation_msg);
317 
324  template <typename T>
325  void addPrivateParam(const std::string & name, const T & value);
326  template <typename T>
327  void addPrivateParam(const std::string & name);
328 
338  template <typename T>
339  void addRequiredCommandLineParam(const std::string & name,
340  const std::string & syntax,
341  const std::string & doc_string);
342  template <typename T>
343  void addCommandLineParam(const std::string & name,
344  const std::string & syntax,
345  const std::string & doc_string);
346  template <typename T>
347  void addCommandLineParam(const std::string & name,
348  const std::string & syntax,
349  const T & value,
350  const std::string & doc_string);
351  template <typename T>
352  void addCommandLineParam(const std::string & name,
353  const std::string & syntax,
354  const std::initializer_list<typename T::value_type> & value,
355  const std::string & doc_string)
356  {
357  addCommandLineParam<T>(name, syntax, T{value}, doc_string);
358  }
359 
377  template <typename T>
378  void addOptionalValuedCommandLineParam(const std::string & name,
379  const std::string & syntax,
380  const T & value,
381  const std::string & doc_string);
382 
388  void setGlobalCommandLineParam(const std::string & name);
389 
397  template <typename T>
398  void addDeprecatedParam(const std::string & name,
399  const T & value,
400  const std::string & doc_string,
401  const std::string & deprecation_message);
402 
403  template <typename T>
404  void addDeprecatedParam(const std::string & name,
405  const std::string & doc_string,
406  const std::string & deprecation_message);
407 
417  template <typename T>
418  void checkConsistentType(const std::string & name) const;
419 
423  bool isCommandLineParameter(const std::string & name) const;
424 
430  std::optional<InputParameters::CommandLineMetadata>
431  queryCommandLineMetadata(const std::string & name) const;
432 
437  getCommandLineMetadata(const std::string & name) const;
438 
444  {
445  friend class CommandLine;
446  FRIEND_TEST(InputParametersTest, commandLineParamSetNotCLParam);
449  };
455  void commandLineParamSet(const std::string & name, const CommandLineParamSetKey);
456 
460  const std::string & getDescription(const std::string & name) const;
461 
467  void addParamNamesToGroup(const std::string & space_delim_names, const std::string group_name);
468 
474  void renameParameterGroup(const std::string & old_name, const std::string & new_name);
475 
480  std::string getGroupName(const std::string & param_name) const;
481 
488  template <typename T>
489  void suppressParameter(const std::string & name);
490 
495  template <typename T>
496  void makeParamRequired(const std::string & name);
497 
502  template <typename T>
503  void makeParamNotRequired(const std::string & name);
504 
510  void addCoupledVar(const std::string & name, const std::string & doc_string);
511 
519  void addDeprecatedCoupledVar(const std::string & old_name,
520  const std::string & new_name,
521  const std::string & removal_date = "");
522 
531  void addCoupledVar(const std::string & name, const Real value, const std::string & doc_string);
532 
541  void addCoupledVar(const std::string & name,
542  const std::vector<Real> & value,
543  const std::string & doc_string);
544 
546 
563  void addCoupledVarWithAutoBuild(const std::string & name,
564  const std::string & base_name,
565  const std::string & num_name,
566  const std::string & doc_string);
567  void addRequiredCoupledVarWithAutoBuild(const std::string & name,
568  const std::string & base_name,
569  const std::string & num_name,
570  const std::string & doc_string);
572 
578  std::string getMooseType(const std::string & name) const;
579  std::vector<std::string> getVecMooseType(const std::string & name) const;
580 
588  bool isMooseBaseObject() const;
589 
593  const std::string * queryObjectType() const;
594 
600  const std::string & getObjectType() const;
604  const std::string & getObjectName() const;
605 
615  void addRequiredCoupledVar(const std::string & name, const std::string & doc_string);
616 
620  std::string getDocString(const std::string & name) const;
621 
629  void setDocString(const std::string & name, const std::string & doc);
630 
634  std::string getDocUnit(const std::string & name) const;
635 
642  void setDocUnit(const std::string & name, const std::string & doc_unit);
643 
647  bool isParamRequired(const std::string & name) const;
648 
652  void makeParamNotRequired(const std::string & name);
653 
659  bool isParamValid(const std::string & name) const;
660 
666  bool isParamSetByAddParam(const std::string & name) const;
667 
671  bool isParamDeprecated(const std::string & name) const;
672 
673 #ifdef MOOSE_KOKKOS_ENABLED
674 
678  bool isKokkosObject() const;
679 #endif
680 
685  bool areAllRequiredParamsValid() const;
686 
690  std::string type(const std::string & name) const;
691 
695  bool isPrivate(const std::string & name) const;
696 
700  void declareControllable(const std::string & name, std::set<ExecFlagType> execute_flags = {});
701 
705  void markControlled(const std::string & name);
706 
710  bool isControllable(const std::string & name) const;
711 
715  const std::set<ExecFlagType> & getControllableExecuteOnTypes(const std::string & name) const;
716 
722  void registerBase(const std::string & value);
723 
729  bool hasBase() const;
730 
736  const std::string & getBase() const;
737 
749  void registerSystemAttributeName(const std::string & value);
750 
755  const std::string & getSystemAttributeName() const;
756 
764  void registerBuildableTypes(const std::string & names);
765 
781  const std::string & name,
783  Moose::RelationshipManagerInputParameterCallback input_parameter_callback = nullptr);
784 
789 
793  const std::vector<std::string> & getBuildableTypes() const;
794 
798  const std::vector<std::tuple<std::string,
802 
804 
808  void collapseSyntaxNesting(bool collapse);
809  bool collapseSyntaxNesting() const;
811 
813 
817  void mooseObjectSyntaxVisibility(bool visibility);
818  bool mooseObjectSyntaxVisibility() const;
820 
822 
825  using Parameters::operator=;
826  using Parameters::operator+=;
830 
837  void checkParams(const std::string & parsing_syntax);
838 
848  std::optional<std::pair<bool, std::string>> parameterRangeCheck(const Parameters::Value & value,
849  const std::string & long_name,
850  const std::string & short_name,
851  const bool include_param_path);
852 
860  void finalize(const std::string & parsing_syntax);
861 
875  std::filesystem::path
876  getFileBase(const std::optional<std::string> & param_name = std::optional<std::string>()) const;
877 
882  inline std::set<std::string>::const_iterator coupledVarsBegin() const
883  {
884  return _coupled_vars.begin();
885  }
886  inline std::set<std::string>::const_iterator coupledVarsEnd() const
887  {
888  return _coupled_vars.end();
889  }
890 
894  const std::set<std::string> & getCoupledVariableParamNames() const { return _coupled_vars; }
895 
899  const std::unordered_map<std::string, std::string> & getNewToDeprecatedVarMap() const
900  {
902  }
903 
905  bool isRangeChecked(const std::string & param_name) const;
906 
908  std::string rangeCheckedFunction(const std::string & name) const;
909 
911  bool hasDefault(const std::string & param_name) const;
912 
918  bool hasCoupledVar(const std::string & coupling_name) const;
919 
925  bool hasCoupledValue(const std::string & coupling_name) const
926  {
927  mooseDeprecated("InputParameters::hasCoupledValue() is deprecated. Use "
928  "InputParameters::hasCoupledVar() instead.");
929  return hasCoupledVar(coupling_name);
930  }
931 
938  void setCoupledVar(const std::string & coupling_name, const std::string & value);
939 
946  void setCoupledVar(const std::string & coupling_name, const std::vector<VariableName> & values);
947 
953  const std::vector<VariableName> & getCoupledVar(const std::string & coupling_name) const;
954 
960  bool hasDefaultCoupledValue(const std::string & coupling_name) const;
961 
968  Real defaultCoupledValue(const std::string & coupling_name, unsigned int i = 0) const;
969 
975  unsigned int numberDefaultCoupledValues(const std::string & coupling_name) const;
976 
984  void defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i = 0);
985 
989  std::map<std::string, std::pair<std::string, std::string>> getAutoBuildVectors() const;
990 
991  // BEGIN APPLY PARAMETER METHODS
1009  void applyParameters(const InputParameters & common,
1010  const std::vector<std::string> & exclude = {},
1011  const bool allow_private = false);
1012 
1018  void applyCommonUserSetParameters(const InputParameters & common,
1019  const std::vector<std::string> & exclude = {},
1020  const bool allow_private = false);
1021 
1039  void applySpecificParameters(const InputParameters & common,
1040  const std::vector<std::string> & include,
1041  bool allow_private = false);
1042 
1054  void applyParameter(const InputParameters & common,
1055  const std::string & common_name,
1056  bool allow_private = false);
1057  // END APPLY PARAMETER METHODS
1058 
1069  void applyCoupledVar(const InputParameters & common, const std::string & var_name);
1070 
1074  bool paramSetByUser(const std::string & name) const;
1075 
1080  bool isParamSetByUser(const std::string & name) const;
1081 
1087  bool isParamDefined(const std::string & name) const;
1088 
1097  template <typename T>
1098  const T * queryParam(const std::string & name) const;
1099 
1101  /*
1102  * These methods are here to retrieve parameters for scalar and vector types respectively. We will
1103  * throw errors
1104  * when returning most scalar and vector types.
1105  */
1106  template <typename T>
1107  static const T & getParamHelper(const std::string & name, const InputParameters & pars);
1109 
1110  using Parameters::get;
1111 
1113  template <typename R1,
1114  typename R2,
1115  typename V1 = typename std::conditional<std::is_same<R1, MooseEnumItem>::value,
1117  std::vector<R1>>::type,
1118  typename V2 = typename std::conditional<std::is_same<R2, MooseEnumItem>::value,
1120  std::vector<R2>>::type>
1121  std::vector<std::pair<R1, R2>> get(const std::string & param1, const std::string & param2) const;
1122 
1126  std::set<std::string> getParametersList() const;
1127 
1131  std::set<std::string> getControllableParameters() const;
1132 
1136  std::set<std::string> getGroupParameters(const std::string & group) const;
1137 
1142  void setReservedValues(const std::string & name, const std::set<std::string> & reserved);
1143 
1148  std::set<std::string> reservedValues(const std::string & name) const;
1149 
1154  std::string blockLocation() const;
1155 
1160  std::string blockFullpath() const;
1161 
1165  const hit::Node * getHitNode(const std::string & param) const;
1171  void setHitNode(const std::string & param, const hit::Node & node, const SetParamHitNodeKey);
1172 
1177  std::string inputLocation(const std::string & param) const;
1178 
1183  std::string paramFullpath(const std::string & param) const;
1184 
1188  std::string paramLocationPrefix(const std::string & param) const;
1189 
1197  template <typename... Args>
1198  std::string paramMessage(const std::string & param, Args... args) const;
1199 
1203  template <typename... Args>
1204  [[noreturn]] void mooseError(Args &&... args) const;
1205 
1210  template <typename... Args>
1211  [[noreturn]] void paramError(const std::string & param, Args... args) const;
1212 
1217  std::string rawParamVal(const std::string & param) const;
1218 
1223  template <typename T>
1224  void ignoreParameter(const std::string & name);
1225 
1230  bool shouldIgnore(const std::string & name);
1231 
1235  template <typename T>
1236  bool isType(const std::string & name) const;
1237 
1244  std::string varName(const std::string & var_param_name,
1245  const std::string & moose_object_with_var_param_name) const;
1246 
1254  void renameParam(const std::string & old_name,
1255  const std::string & new_name,
1256  const std::string & new_docstring);
1257 
1264  void renameCoupledVar(const std::string & old_name,
1265  const std::string & new_name,
1266  const std::string & new_docstring);
1267 
1268  void deprecateParam(const std::string & old_name,
1269  const std::string & new_name,
1270  const std::string & removal_date);
1271 
1272  void deprecateCoupledVar(const std::string & old_name,
1273  const std::string & new_name,
1274  const std::string & removal_date);
1275 
1282  std::string checkForRename(const std::string & name) const;
1283 
1290  template <typename T>
1291  const T & get(std::string_view name) const;
1292 
1301  template <typename T>
1302  bool have_parameter(std::string_view name) const;
1303 
1311  template <typename T>
1312  void transferParam(const InputParameters & source_param,
1313  const std::string & name,
1314  const std::string & new_name = "",
1315  const std::string & new_description = "");
1316 
1329  std::vector<std::string> paramAliases(const std::string & param_name) const;
1330 
1335  const hit::Node * getHitNode() const { return _hit_node; }
1343  void setHitNode(const hit::Node & node, const SetHitNodeKey) { _hit_node = &node; }
1344 
1348  bool isFinalized() const { return _finalized; }
1349 
1353  std::optional<Moose::DataFileUtils::Path> queryDataFileNamePath(const std::string & name) const;
1354 
1363  std::optional<std::string> setupVariableNames(std::vector<VariableName> & names,
1364  const hit::Node & node,
1366 
1367 private:
1368  // Private constructor so that InputParameters can only be created in certain places.
1369  InputParameters();
1370 
1374  void setParameters() {}
1375 
1376  template <typename T>
1377  static constexpr bool isFunctorNameType();
1378 
1382  template <typename T>
1383  std::string appendFunctorDescription(const std::string & doc_string) const;
1384 
1388  void setDeprecatedVarDocString(const std::string & new_name, const std::string & doc_string);
1389 
1390  void renameParamInternal(const std::string & old_name,
1391  const std::string & new_name,
1392  const std::string & docstring,
1393  const std::string & removal_date);
1394 
1395  void renameCoupledVarInternal(const std::string & old_name,
1396  const std::string & new_name,
1397  const std::string & docstring,
1398  const std::string & removal_date);
1399 
1406  std::pair<std::string, const hit::Node *> paramMessageContext(const std::string & param) const;
1412  std::string paramMessagePrefix(const std::string & param) const;
1413 
1414  struct Metadata
1415  {
1416  std::string _doc_string;
1418  std::string _doc_unit;
1420  std::string _custom_type;
1422  std::optional<CommandLineMetadata> _cl_data;
1424  std::optional<Moose::DataFileUtils::Path> _data_file_name_path;
1426  std::string _group;
1428  std::string _range_function;
1430  std::pair<std::string, std::string> _autobuild_vecs;
1432  bool _required = false;
1438  bool _valid = false;
1440  bool _is_private = false;
1443  std::vector<Real> _coupled_default = {0};
1445  bool _set_by_add_param = false;
1447  std::set<std::string> _reserved_values;
1451  const hit::Node * _hit_node;
1453  bool _controllable = false;
1455  std::set<ExecFlagType> _controllable_flags;
1457  bool _ignore = false;
1458  };
1459 
1460  Metadata & at(const std::string & param_name)
1461  {
1462  const auto param = checkForRename(param_name);
1463  if (_params.count(param) == 0)
1464  mooseError("param '", param, "' not present in InputParams");
1465  return _params[param];
1466  }
1467  const Metadata & at(const std::string & param_name) const
1468  {
1469  const auto param = checkForRename(param_name);
1470  if (_params.count(param) == 0)
1471  mooseError("param '", param, "' not present in InputParams");
1472  return _params.at(param);
1473  }
1474 
1485 
1489  void checkParamName(const std::string & name) const;
1490 
1495  template <typename T, typename S>
1496  void setParamHelper(const std::string & name, T & l_value, const S & r_value);
1497 
1506  template <typename T>
1507  void addCommandLineParamHelper(const std::string & name,
1508  const std::string & syntax,
1509  const bool required,
1510  const bool value_required);
1511 
1516  [[noreturn]] void callMooseError(std::string msg,
1517  const bool with_prefix = true,
1518  const hit::Node * node = nullptr,
1519  const bool show_trace = true) const;
1520 
1523  std::map<std::string, Metadata> _params;
1524 
1526  std::set<std::string> _coupled_vars;
1527 
1530  std::string _class_description;
1531 
1534  std::vector<std::string> _buildable_types;
1535 
1540  std::vector<std::tuple<std::string,
1544 
1548 
1551 
1555 
1558 
1560  std::unordered_map<std::string, std::string> _new_to_deprecated_coupled_vars;
1561 
1566  std::map<std::string, std::pair<std::string, std::string>> _old_to_new_name_and_dep;
1567 
1570  std::multimap<std::string, std::string> _new_to_old_names;
1571 
1573  const hit::Node * _hit_node;
1574 
1577 
1578  // These are the only objects allowed to _create_ InputParameters
1581  friend class Parser;
1582  // for the printInputFile function in the action warehouse
1583  friend class ActionWarehouse;
1584 };
1585 
1586 template <typename T>
1587 void
1588 InputParameters::setHelper(const std::string & /*name*/)
1589 {
1590 }
1591 
1592 // Template and inline function implementations
1593 template <typename T>
1594 T &
1595 InputParameters::set(const std::string & name_in, bool quiet_mode)
1596 {
1597  const auto name = checkForRename(name_in);
1598 
1600  checkConsistentType<T>(name);
1601 
1602  T & result = this->Parameters::set<T>(name);
1603 
1604  if (quiet_mode)
1605  _params[name]._set_by_add_param = true;
1606 
1607  setHelper<T>(name);
1608 
1609  return result;
1610 }
1611 
1612 template <typename T, typename... Ts>
1613 void
1614 InputParameters::setParameters(const std::string & name,
1615  const T & value,
1616  Ts... extra_input_parameters)
1617 {
1618  this->set<T>(name) = value;
1619  this->setParameters(extra_input_parameters...);
1620 }
1621 
1622 template <typename T, typename UP_T>
1623 std::optional<std::pair<bool, std::string>>
1624 InputParameters::rangeCheck(const std::string & full_name,
1625  const std::string & short_name,
1626  const InputParameters::Parameter<std::vector<T>> & param,
1627  const bool include_param_path)
1628 {
1629  if (!isParamValid(short_name))
1630  return {};
1631 
1632  const auto & range_function = _params[short_name]._range_function;
1633  if (range_function.empty())
1634  return {};
1635 
1648  std::vector<std::string> vars;
1649  if (fp.ParseAndDeduceVariables(range_function, vars) != -1) // -1 for success
1650  return {{false,
1651  "Error parsing expression '" + range_function + "' for parameter " + short_name + ""}};
1652 
1653  // Fparser parameter buffer
1654  std::vector<UP_T> parbuf(vars.size());
1655 
1656  // parameter vector
1657  const std::vector<T> & value = param.get();
1658 
1659  // iterate over all vector values (maybe ;)
1660  bool need_to_iterate = false;
1661  unsigned int i = 0;
1662  do
1663  {
1664  // set parameters
1665  for (unsigned int j = 0; j < vars.size(); j++)
1666  {
1667  if (vars[j] == short_name)
1668  {
1669  if (value.size() == 0)
1670  {
1671  std::ostringstream oss;
1672  oss << "Range checking empty vector";
1673  if (include_param_path)
1674  oss << " parameter " << full_name;
1675  oss << "; expression = '" << range_function << "'";
1676  return {{true, oss.str()}};
1677  }
1678 
1679  parbuf[j] = value[i];
1680  need_to_iterate = true;
1681  }
1682  else if (vars[j] == short_name + "_size")
1683  parbuf[j] = value.size();
1684  else
1685  {
1686  if (vars[j].substr(0, short_name.size() + 1) != short_name + "_")
1687  return {{false, "Error parsing expression '" + range_function + "'"}};
1688  std::istringstream iss(vars[j]);
1689  iss.seekg(short_name.size() + 1);
1690 
1691  size_t index;
1692  if (iss >> index && iss.eof())
1693  {
1694  if (index >= value.size())
1695  {
1696  std::ostringstream oss;
1697  oss << "Error parsing expression '" + range_function + "'";
1698  if (include_param_path)
1699  oss << " for parameter " << full_name;
1700  oss << "; out of range variable '" + vars[j] << "'";
1701  return {{true, oss.str()}};
1702  }
1703  parbuf[j] = value[index];
1704  }
1705  else
1706  return {{false,
1707  "Error parsing expression '" + range_function + "'; invalid variable '" +
1708  vars[j] + "'"}};
1709  }
1710  }
1711 
1712  // ensure range-checked input file parameter comparison functions
1713  // do absolute floating point comparisons instead of using a default epsilon.
1714  auto tmp_eps = fp.epsilon();
1715  fp.setEpsilon(0);
1716  UP_T result = fp.Eval(&parbuf[0]);
1717  fp.setEpsilon(tmp_eps);
1718 
1719  // test function using the parameters determined above
1720  if (fp.EvalError())
1721  return {{false, "Error evaluating expression '" + range_function + "'"}};
1722 
1723  if (!result)
1724  {
1725  std::ostringstream oss;
1726  oss << "Range check failed";
1727  if (include_param_path)
1728  oss << " for parameter " << full_name;
1729  oss << "; expression = '" << range_function << "'";
1730  if (need_to_iterate)
1731  oss << ", component " << i;
1732  return {{true, oss.str()}};
1733  }
1734 
1735  } while (need_to_iterate && ++i < value.size());
1736 
1737  return {};
1738 }
1739 
1740 template <typename T, typename UP_T>
1741 std::optional<std::pair<bool, std::string>>
1742 InputParameters::rangeCheck(const std::string & full_name,
1743  const std::string & short_name,
1744  const InputParameters::Parameter<T> & param,
1745  const bool include_param_path)
1746 {
1747  if (!isParamValid(short_name))
1748  return {};
1749 
1750  const auto & range_function = _params[short_name]._range_function;
1751  if (range_function.empty())
1752  return {};
1753 
1754  // Parse the expression
1756  if (fp.Parse(range_function, short_name) != -1) // -1 for success
1757  return {{false,
1758  "Error parsing expression '" + range_function + "'" + " for parameter " + short_name}};
1759 
1760  // ensure range-checked input file parameter comparison functions
1761  // do absolute floating point comparisons instead of using a default epsilon.
1762  auto tmp_eps = fp.epsilon();
1763  fp.setEpsilon(0);
1764  // We require a non-const value for the implicit upscaling of the parameter type
1765  std::vector<UP_T> value(1, param.get());
1766  UP_T result = fp.Eval(&value[0]);
1767  fp.setEpsilon(tmp_eps);
1768 
1769  if (fp.EvalError())
1770  return {{true,
1771  "Error evaluating expression '" + range_function + "' for parameter " + short_name +
1772  "; perhaps you used the wrong variable name?"}};
1773 
1774  if (!result)
1775  {
1776  std::ostringstream oss;
1777  oss << "Range check failed";
1778  if (include_param_path)
1779  oss << " for parameter " << full_name;
1780  oss << "; expression = '" << range_function << "', value = " << value[0];
1781  return {{true, oss.str()}};
1782  }
1783 
1784  return {};
1785 }
1786 
1787 template <typename T>
1788 T
1789 InputParameters::getCheckedPointerParam(const std::string & name_in,
1790  const std::string & error_string) const
1791 {
1792  const auto name = checkForRename(name_in);
1793 
1794  T param = this->get<T>(name);
1795 
1796  // Note: You will receive a compile error on this line if you attempt to pass a non-pointer
1797  // template type to this method
1798  if (!param)
1799  mooseError("Parameter ", name, " is NULL.\n", error_string);
1800  return this->get<T>(name);
1801 }
1802 
1803 template <typename T>
1804 void
1805 InputParameters::addRequiredParam(const std::string & name, const std::string & doc_string)
1806 {
1808  checkConsistentType<T>(name);
1809 
1810  InputParameters::insert<T>(name);
1811  auto & metadata = _params[name];
1812  metadata._required = true;
1813  if constexpr (isFunctorNameType<T>())
1814  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1815  else
1816  metadata._doc_string = doc_string;
1817 }
1818 
1819 template <typename T>
1820 void
1821 InputParameters::addRequiredParam(const std::string & /*name*/,
1822  const T & /*value*/,
1823  const std::string & /*doc_string*/)
1824 {
1825  mooseError("You cannot call addRequiredParam and supply a default value for this type, please "
1826  "use addParam instead");
1827 }
1828 
1829 template <typename T, typename S>
1830 void
1831 InputParameters::addParam(const std::string & name, const S & value, const std::string & doc_string)
1832 {
1834  checkConsistentType<T>(name);
1835 
1836  T & l_value = InputParameters::set<T>(name);
1837  auto & metadata = _params[name];
1838  if constexpr (isFunctorNameType<T>())
1839  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1840  else
1841  metadata._doc_string = doc_string;
1842 
1843  // Set the parameter now
1844  setParamHelper(name, l_value, value);
1845 
1846  /* Indicate the default value, as set via addParam, is being used. The parameter is removed from
1847  the list whenever
1848  it changes, see set_attributes */
1849  metadata._set_by_add_param = true;
1850 }
1851 
1852 template <typename T>
1853 void
1854 InputParameters::addParam(const std::string & name, const std::string & doc_string)
1855 {
1857  checkConsistentType<T>(name);
1858 
1859  InputParameters::insert<T>(name);
1860  if constexpr (isFunctorNameType<T>())
1861  _params[name]._doc_string = appendFunctorDescription<T>(doc_string);
1862  else
1863  _params[name]._doc_string = doc_string;
1864 }
1865 
1866 template <typename T, typename S>
1867 void
1868 InputParameters::setParamHelper(const std::string & /*name*/, T & l_value, const S & r_value)
1869 {
1870  l_value = r_value;
1871 }
1872 
1873 template <typename T>
1874 void
1876  const std::string & syntax,
1877  const bool required,
1878  const bool value_required)
1879 {
1880  static_assert(isValidCommandLineType<T>::value,
1881  "This type is not a supported command line parameter type. See "
1882  "CommandLine::populateCommandLineParams to add it as a supported type.");
1883 
1884  auto & cl_data = at(name)._cl_data;
1885  cl_data = CommandLineMetadata();
1886 
1887  // Split up the syntax by whitespace
1888  std::vector<std::string> syntax_split;
1889  MooseUtils::tokenize(syntax, syntax_split, 1, " \t\n\v\f\r");
1890 
1891  // Set the single syntax string as the combined syntax with removed whitespace
1892  cl_data->syntax = MooseUtils::stringJoin(syntax_split);
1893  mooseAssert(cl_data->syntax.size(), "Empty token");
1894 
1895  // Set the switches; only parse those that begin with "-" as we also
1896  // provide examples within the syntax
1897  for (const auto & val : syntax_split)
1898  if (val.rfind("-", 0) == 0)
1899  {
1900  if (!std::regex_search(val, std::regex("^\\-+[a-zA-Z]")))
1901  mooseError("The switch '",
1902  val,
1903  "' for the command line parameter '",
1904  name,
1905  "' is invalid. It must begin with an alphabetical character.");
1906 
1907  cl_data->switches.push_back(val);
1909  }
1910 
1911  cl_data->required = required;
1912  cl_data->global = false;
1913 
1914  // No arguments needed for a boolean parameter
1915  if constexpr (std::is_same_v<T, bool>)
1916  {
1917  (void)value_required; // purposely unused; doesn't take a value
1918  cl_data->argument_type = CommandLineMetadata::ArgumentType::NONE;
1919  }
1920  // MooseEnums require a value
1921  else if constexpr (std::is_same_v<T, MooseEnum>)
1922  {
1923  (void)value_required; // purposely unused; always required
1924  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1925  }
1926  // The user didn't specify a default, so a value is required
1927  else if (value_required)
1928  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1929  // Otherwise, it's optional (user specified a default)
1930  else
1931  cl_data->argument_type = CommandLineMetadata::ArgumentType::OPTIONAL;
1932 }
1933 
1934 template <typename T>
1935 void
1937  const std::string & parsed_function,
1938  const std::string & doc_string)
1939 {
1940  addRequiredParam<T>(name, doc_string);
1941  _params[name]._range_function = parsed_function;
1942 }
1943 
1944 template <typename T>
1945 void
1946 InputParameters::addRangeCheckedParam(const std::string & name,
1947  const T & value,
1948  const std::string & parsed_function,
1949  const std::string & doc_string)
1950 {
1951  addParam<T>(name, value, doc_string);
1952  _params[name]._range_function = parsed_function;
1953 }
1954 
1955 template <typename T>
1956 void
1957 InputParameters::addRangeCheckedParam(const std::string & name,
1958  const std::string & parsed_function,
1959  const std::string & doc_string)
1960 {
1961  addParam<T>(name, doc_string);
1962  _params[name]._range_function = parsed_function;
1963 }
1964 
1965 template <typename T>
1966 void
1968  const std::string & custom_type,
1969  const std::string & doc_string)
1970 {
1971  addRequiredParam<T>(name, doc_string);
1972  _params[name]._custom_type = custom_type;
1973 }
1974 
1975 template <typename T>
1976 void
1977 InputParameters::addCustomTypeParam(const std::string & name,
1978  const T & value,
1979  const std::string & custom_type,
1980  const std::string & doc_string)
1981 {
1982  addParam<T>(name, value, doc_string);
1983  _params[name]._custom_type = custom_type;
1984 }
1985 
1986 template <typename T>
1987 void
1988 InputParameters::addCustomTypeParam(const std::string & name,
1989  const std::string & custom_type,
1990  const std::string & doc_string)
1991 {
1992  addParam<T>(name, doc_string);
1993  _params[name]._custom_type = custom_type;
1994 }
1995 
1996 template <typename T>
1997 void
1999  const std::string & custom_type,
2000  const std::string & doc_string,
2001  const std::string & deprecation_message)
2002 {
2003  _show_deprecated_message = false;
2004  addParam<T>(name, doc_string);
2005  auto & metadata = _params[name];
2006  metadata._custom_type = custom_type;
2007 
2008  metadata._deprecation_message = deprecation_message;
2009  _show_deprecated_message = true;
2010 }
2011 
2012 template <typename T>
2013 void
2014 InputParameters::addPrivateParam(const std::string & name)
2015 {
2017  checkConsistentType<T>(name);
2018 
2019  InputParameters::insert<T>(name);
2020  _params[name]._is_private = true;
2021 }
2022 
2023 template <typename T>
2024 void
2025 InputParameters::addPrivateParam(const std::string & name, const T & value)
2026 {
2028  checkConsistentType<T>(name);
2029 
2030  InputParameters::set<T>(name) = value;
2031  auto & metadata = _params[name];
2032  metadata._is_private = true;
2033  metadata._set_by_add_param = true;
2034 }
2035 
2036 template <typename T>
2037 void
2039  const std::string & syntax,
2040  const std::string & doc_string)
2041 {
2042  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool");
2043 
2044  addRequiredParam<T>(name, doc_string);
2045  addCommandLineParamHelper<T>(name, syntax, /* required = */ true, /* value_required = */ true);
2046 }
2047 
2048 template <typename T>
2049 void
2050 InputParameters::addCommandLineParam(const std::string & name,
2051  const std::string & syntax,
2052  const std::string & doc_string)
2053 {
2054  static_assert(!std::is_same_v<T, MooseEnum>,
2055  "addCommandLineParam() without a value cannot be used with a MooseEnum because a "
2056  "MooseEnum requires initialization");
2057 
2058  auto constexpr is_bool = std::is_same_v<T, bool>;
2059  if constexpr (is_bool)
2060  addParam<T>(name, false, doc_string);
2061  else
2062  addParam<T>(name, doc_string);
2063 
2064  addCommandLineParamHelper<T>(
2065  name, syntax, /* required = */ false, /* value_required = */ !is_bool);
2066 }
2067 
2068 template <typename T>
2069 void
2070 InputParameters::addCommandLineParam(const std::string & name,
2071  const std::string & syntax,
2072  const T & value,
2073  const std::string & doc_string)
2074 {
2075  if constexpr (std::is_same_v<T, bool>)
2076  mooseAssert(!value, "Default for bool must be false");
2077 
2078  addParam<T>(name, value, doc_string);
2079  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ true);
2080 }
2081 
2082 template <typename T>
2083 void
2085  const std::string & syntax,
2086  const T & value,
2087  const std::string & doc_string)
2088 {
2089  mooseAssert(name == "citations" || name == "csg_only" || name == "mesh_only" ||
2090  name == "recover" || name == "run",
2091  "Not supported for new parameters");
2092  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool (does not take a value)");
2093  addParam<T>(name, value, doc_string);
2094  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ false);
2095 }
2096 
2097 template <typename T>
2098 void
2099 InputParameters::checkConsistentType(const std::string & name_in) const
2100 {
2101  const auto name = checkForRename(name_in);
2102 
2103  // If we don't currently have the Parameter, can't be any inconsistency
2105  if (it == _values.end())
2106  return;
2107 
2108  // Now, if we already have the Parameter, but it doesn't have the
2109  // right type, throw an error.
2110  if (!this->Parameters::have_parameter<T>(name))
2111  mooseError("Attempting to set parameter \"",
2112  name,
2113  "\" with type (",
2114  libMesh::demangle(typeid(T).name()),
2115  ")\nbut the parameter already exists as type (",
2116  it->second->type(),
2117  ")");
2118 }
2119 
2120 template <typename T>
2121 void
2122 InputParameters::suppressParameter(const std::string & name_in)
2123 {
2124  const auto name = checkForRename(name_in);
2125  if (!this->have_parameter<T>(name))
2126  mooseError("Unable to suppress nonexistent parameter: ", name);
2127 
2128  auto & metadata = _params[name];
2129  metadata._required = false;
2130  metadata._is_private = true;
2131  metadata._controllable = false;
2132 }
2133 
2134 template <typename T>
2135 void
2136 InputParameters::ignoreParameter(const std::string & name_in)
2137 {
2138  const auto name = checkForRename(name_in);
2139  suppressParameter<T>(name);
2140  _params[name]._ignore = true;
2141 }
2142 
2143 template <typename T>
2144 void
2145 InputParameters::makeParamRequired(const std::string & name_in)
2146 {
2147  const auto name = checkForRename(name_in);
2148 
2149  if (!this->have_parameter<T>(name))
2150  mooseError("Unable to require nonexistent parameter: ", name);
2151 
2152  _params[name]._required = true;
2153 }
2154 
2155 template <typename T>
2156 void
2157 InputParameters::makeParamNotRequired(const std::string & name_in)
2158 {
2159  const auto name = checkForRename(name_in);
2160 
2161  if (!this->have_parameter<T>(name))
2162  mooseError("Unable to un-require nonexistent parameter: ", name);
2163 
2164  _params[name]._required = false;
2165 }
2166 
2167 template <typename T>
2168 void
2169 InputParameters::addDeprecatedParam(const std::string & name,
2170  const T & value,
2171  const std::string & doc_string,
2172  const std::string & deprecation_message)
2173 {
2174  _show_deprecated_message = false;
2175  mooseAssert(!_old_to_new_name_and_dep.count(name),
2176  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2177  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2178  addParam<T>(name, value, doc_string);
2179 
2180  _params[name]._deprecation_message = deprecation_message;
2181  _show_deprecated_message = true;
2182 }
2183 
2184 template <typename T>
2185 void
2186 InputParameters::addDeprecatedParam(const std::string & name,
2187  const std::string & doc_string,
2188  const std::string & deprecation_message)
2189 {
2190  _show_deprecated_message = false;
2191  mooseAssert(!_old_to_new_name_and_dep.count(name),
2192  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2193  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2194  addParam<T>(name, doc_string);
2195 
2196  _params[name]._deprecation_message = deprecation_message;
2197  _show_deprecated_message = true;
2198 }
2199 
2200 // Forward declare MooseEnum specializations for add*Param
2201 template <>
2202 void InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
2203  const MooseEnum & moose_enum,
2204  const std::string & doc_string);
2205 
2206 template <>
2207 void InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
2208  const MultiMooseEnum & moose_enum,
2209  const std::string & doc_string);
2210 
2211 template <>
2212 void InputParameters::addRequiredParam<std::vector<MooseEnum>>(
2213  const std::string & name,
2214  const std::vector<MooseEnum> & moose_enums,
2215  const std::string & doc_string);
2216 
2217 template <>
2218 void InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
2219  const std::string & name,
2220  const std::vector<MultiMooseEnum> & moose_enums,
2221  const std::string & doc_string);
2222 
2223 template <>
2224 void InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
2225  const std::string & /*doc_string*/);
2226 
2227 template <>
2228 void InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
2229  const std::string & /*doc_string*/);
2230 
2231 template <>
2232 void InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
2233  const std::string & /*doc_string*/);
2234 
2235 template <>
2236 void InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2237  const std::string & /*doc_string*/);
2238 
2239 template <>
2240 void
2241 InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2242  const std::string & /*doc_string*/);
2243 
2244 template <>
2245 void InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/);
2246 
2247 template <>
2248 void InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/);
2249 
2250 template <>
2251 void InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
2252  const std::string & /*doc_string*/,
2253  const std::string & /*deprecation_message*/);
2254 
2255 template <>
2256 void
2257 InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
2258  const std::string & /*doc_string*/,
2259  const std::string & /*deprecation_message*/);
2260 
2261 template <>
2262 void InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
2263  const std::string & /*name*/,
2264  const std::string & /*doc_string*/,
2265  const std::string & /*deprecation_message*/);
2266 
2267 // Forward declare specializations for setParamHelper
2268 template <>
2269 void InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & name,
2270  PostprocessorName & l_value,
2271  const Real & r_value);
2272 
2273 template <>
2274 void InputParameters::setParamHelper<PostprocessorName, int>(const std::string & name,
2275  PostprocessorName & l_value,
2276  const int & r_value);
2277 
2278 template <>
2279 void InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
2280  FunctionName & l_value,
2281  const Real & r_value);
2282 
2283 template <>
2284 void InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
2285  FunctionName & l_value,
2286  const int & r_value);
2287 
2288 template <>
2289 void InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
2290  MaterialPropertyName & l_value,
2291  const Real & r_value);
2292 
2293 template <>
2294 void InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
2295  MaterialPropertyName & l_value,
2296  const int & r_value);
2297 
2298 template <>
2299 void InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
2300  MooseFunctorName & l_value,
2301  const Real & r_value);
2302 
2303 template <>
2304 void InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
2305  MooseFunctorName & l_value,
2306  const int & r_value);
2307 
2308 template <typename T>
2309 const T *
2310 InputParameters::queryParam(const std::string & name) const
2311 {
2312  return isParamValid(name) ? &getParamHelper<T>(name, *this) : nullptr;
2313 }
2314 
2315 template <typename T>
2316 const T &
2317 InputParameters::getParamHelper(const std::string & name_in, const InputParameters & pars)
2318 {
2319  const auto name = pars.checkForRename(name_in);
2320 
2321  if (!pars.isParamValid(name))
2322  pars.mooseError("The parameter \"", name, "\" is being retrieved before being set.");
2323 
2324  return pars.get<T>(name);
2325 }
2326 
2327 // Declare specializations so we don't fall back on the generic
2328 // implementation, but the definition will be in InputParameters.C so
2329 // we won't need to bring in *MooseEnum header files here.
2330 template <>
2331 const MooseEnum & InputParameters::getParamHelper<MooseEnum>(const std::string & name,
2332  const InputParameters & pars);
2333 
2334 template <>
2335 const MultiMooseEnum &
2336 InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name,
2337  const InputParameters & pars);
2338 
2339 template <typename R1, typename R2, typename V1, typename V2>
2340 std::vector<std::pair<R1, R2>>
2341 InputParameters::get(const std::string & param1_in, const std::string & param2_in) const
2342 {
2343  const auto param1 = checkForRename(param1_in);
2344  const auto param2 = checkForRename(param2_in);
2345 
2346  const auto & v1 = get<V1>(param1);
2347  const auto & v2 = get<V2>(param2);
2348 
2349  auto controllable = getControllableParameters();
2350  if (controllable.count(param1) || controllable.count(param2))
2351  mooseError("Parameters ",
2352  param1,
2353  " and/or ",
2354  param2 + " are controllable parameters and cannot be retireved using "
2355  "the MooseObject::getParam/InputParameters::get methods for pairs");
2356 
2357  if (v1.size() != v2.size())
2358  paramError(param1,
2359  "Vector parameters ",
2360  param1,
2361  "(size: ",
2362  v1.size(),
2363  ") and " + param2,
2364  "(size: ",
2365  v2.size(),
2366  ") are of different lengths \n");
2367 
2368  std::vector<std::pair<R1, R2>> parameter_pairs;
2369  auto i1 = v1.begin();
2370  auto i2 = v2.begin();
2371  for (; i1 != v1.end() && i2 != v2.end(); ++i1, ++i2)
2372  parameter_pairs.emplace_back(std::make_pair(*i1, *i2));
2373  return parameter_pairs;
2374 }
2375 
2377 
2378 template <typename T>
2379 bool
2380 InputParameters::isType(const std::string & name_in) const
2381 {
2382  const auto name = checkForRename(name_in);
2383 
2384  if (!_params.count(name))
2385  mooseError("Parameter \"", name, "\" is not valid.");
2386  return have_parameter<T>(name);
2387 }
2388 
2389 template <typename T>
2390 const T &
2391 InputParameters::get(std::string_view name_in) const
2392 {
2393  const auto name = checkForRename(std::string(name_in));
2394 
2395  return Parameters::get<T>(name);
2396 }
2397 
2398 template <typename T>
2399 bool
2400 InputParameters::have_parameter(std::string_view name_in) const
2401 {
2402  const auto name = checkForRename(std::string(name_in));
2403 
2404  return Parameters::have_parameter<T>(name);
2405 }
2406 
2407 template <typename T>
2408 void
2410  const std::string & name_in,
2411  const std::string & new_name,
2412  const std::string & new_description)
2413 {
2414  const auto name = source_params.checkForRename(std::string(name_in));
2415  const auto p_name = new_name.empty() ? name_in : new_name;
2416  if (!source_params.have_parameter<T>(name) && !source_params.hasCoupledVar(name))
2417  mooseError("The '",
2418  name_in,
2419  "' parameter could not be transferred because it does not exist with type '",
2420  MooseUtils::prettyCppType<T>(),
2421  "' in the source parameters");
2422  if (name != name_in)
2423  mooseWarning("The transferred parameter " + name_in + " is deprecated in favor of " + name +
2424  " in the source parameters. The new name should likely be used for the parameter "
2425  "transfer instead.");
2426  const std::string description =
2427  new_description.empty() ? source_params.getDescription(name) : new_description;
2428 
2429  if (source_params.isParamRequired(name))
2430  {
2431  // Check for a variable parameter
2432  if (source_params.hasCoupledVar(name))
2433  addRequiredCoupledVar(p_name, description);
2434  // Enums parameters have a default list of options
2435  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2436  addRequiredParam<T>(p_name, source_params.get<T>(name), description);
2437  else if (source_params.isRangeChecked(name))
2438  addRequiredRangeCheckedParam<T>(
2439  p_name, source_params.rangeCheckedFunction(name), description);
2440  else
2441  addRequiredParam<T>(p_name, description);
2442  }
2443  else
2444  {
2445  // Check for a variable parameter
2446  if (source_params.hasCoupledVar(name))
2447  {
2448  if (!source_params.hasDefaultCoupledValue(name))
2449  addCoupledVar(p_name, description);
2450  else if (source_params.numberDefaultCoupledValues(name) == 1)
2451  addCoupledVar(p_name, source_params.defaultCoupledValue(name), description);
2452  else
2453  {
2454  std::vector<Real> coupled_values;
2455  for (const auto i : libMesh::make_range(source_params.numberDefaultCoupledValues(name)))
2456  coupled_values.push_back(source_params.defaultCoupledValue(name, i));
2457  addCoupledVar(p_name, coupled_values, description);
2458  }
2459  }
2460  else if (source_params.isRangeChecked(name))
2461  {
2462  if (source_params.hasDefault(name))
2463  addRangeCheckedParam<T>(p_name,
2464  source_params.get<T>(name),
2465  source_params.rangeCheckedFunction(name),
2466  description);
2467  else
2468  addRangeCheckedParam<T>(p_name, source_params.rangeCheckedFunction(name), description);
2469  }
2470  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2471  addParam<T>(p_name, source_params.get<T>(name), description);
2472  else
2473  {
2474  if (source_params.hasDefault(name))
2475  addParam<T>(p_name, source_params.get<T>(name), description);
2476  else
2477  addParam<T>(p_name, description);
2478  }
2479  }
2480 
2481  // Copy other attributes
2482  if (source_params.isPrivate(name))
2483  _params[p_name]._is_private = true;
2484  if (source_params.isControllable(name))
2485  _params[p_name]._controllable = true;
2486 }
2487 
2488 template <typename... Args>
2489 [[noreturn]] void
2490 InputParameters::mooseError(Args &&... args) const
2491 {
2492  std::ostringstream oss;
2493  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2494  callMooseError(oss.str());
2495 }
2496 
2497 template <typename... Args>
2498 std::string
2499 InputParameters::paramMessage(const std::string & param, Args... args) const
2500 {
2501  std::ostringstream oss;
2502  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2503  return paramMessagePrefix(param) + oss.str();
2504 }
2505 
2506 template <typename... Args>
2507 [[noreturn]] void
2508 InputParameters::paramError(const std::string & param, Args... args) const
2509 {
2510  std::ostringstream oss;
2511  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2512  const auto [prefix, node] = paramMessageContext(param);
2513  callMooseError(prefix + oss.str(), false, node, /* show_trace = */ false);
2514 }
2515 
2516 namespace Moose
2517 {
2518 namespace internal
2519 {
2520 template <typename T>
2521 constexpr T *
2523 {
2524  return nullptr;
2525 }
2526 
2527 #ifdef MOOSE_MFEM_ENABLED
2528 
2529 template <typename T>
2530 constexpr bool
2532 {
2533  return std::is_same_v<T, MFEMScalarCoefficientName> ||
2534  std::is_same_v<T, MFEMVectorCoefficientName>;
2535 }
2536 
2537 template <typename T, typename A>
2538 constexpr bool
2539 isMFEMFunctorNameTypeHelper(std::vector<T, A> *)
2540 {
2541  return isMFEMFunctorNameTypeHelper(getNullptrExample<T>());
2542 }
2543 
2544 #endif
2545 
2546 template <typename T>
2547 constexpr bool
2549 {
2550  return std::is_same_v<T, MooseFunctorName>
2551 #ifdef MOOSE_MFEM_ENABLED
2552  || std::is_same_v<T, MFEMScalarCoefficientName>
2553 #endif
2554  ;
2555 }
2556 
2557 template <typename T, typename A>
2558 constexpr bool
2559 isScalarFunctorNameTypeHelper(std::vector<T, A> *)
2560 {
2561  return isScalarFunctorNameTypeHelper(getNullptrExample<T>());
2562 }
2563 
2564 template <typename T>
2565 constexpr bool
2567 {
2568 #ifdef MOOSE_MFEM_ENABLED
2569  return std::is_same_v<T, MFEMVectorCoefficientName>;
2570 #else
2571  return false;
2572 #endif
2573 }
2574 
2575 template <typename T, typename A>
2576 constexpr bool
2577 isVectorFunctorNameTypeHelper(std::vector<T, A> *)
2578 {
2579  return isVectorFunctorNameTypeHelper(getNullptrExample<T>());
2580 }
2581 
2582 template <typename T>
2583 constexpr bool
2585 {
2587 }
2588 }
2589 }
2590 
2591 template <typename T>
2592 constexpr bool
2594 {
2595  return Moose::internal::isFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>());
2596 }
2597 
2598 template <typename T>
2599 std::string
2600 InputParameters::appendFunctorDescription(const std::string & doc_string) const
2601 {
2602  auto numeric_value_type = []()
2603  {
2605  Moose::internal::getNullptrExample<T>()))
2606  return "number";
2608  Moose::internal::getNullptrExample<T>()))
2609  return "numeric vector value (enclosed in curly braces)";
2610  else
2611  {
2612  mooseAssert(false, "We control instantiations of this method");
2613  return "";
2614  }
2615  };
2616 
2617  return MooseUtils::trim(doc_string, ". ") + ". A functor is any of the following: a variable, " +
2618  (
2619 #ifdef MOOSE_MFEM_ENABLED
2620  Moose::internal::isMFEMFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>())
2621  ? "an MFEM"
2622  :
2623 #endif
2624  "a functor") +
2625  " material property, a function, a postprocessor or a " + numeric_value_type() + ".";
2626 }
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)
std::optional< std::string > queryDeprecatedParamMessage(const std::string &name) const
void mooseStreamAll(std::ostringstream &ss)
All of the following are not meant to be called directly - they are called by the normal macros (moos...
Definition: MooseError.C:137
std::string paramMessage(const std::string &param, Args... args) const
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
Determines whether or not the given type is a type that is supported for a command line parameter...
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.
bool isParamDefined(const std::string &name) const
Method returns true if the parameter is defined for any type.
void addCommandLineParamHelper(const std::string &name, const std::string &syntax, const bool required, const bool value_required)
Helper for all of the addCommandLineParam() calls, which sets up _cl_data in the metadata.
void clearRelationshipManagers()
Clears all currently registered RelationshipManagers.
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
void setGlobalCommandLineParam(const std::string &name)
Sets the command line parameter with name as global.
bool hasCoupledValue(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
Storage container for all InputParamter objects.
bool set_by_command_line
Whether or not the parameter was set by the CommandLine.
constexpr bool isVectorFunctorNameTypeHelper(T *)
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 ...
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
bool required
Whether or not the argument is required.
RelationshipManagerType
Main types of Relationship Managers.
Definition: MooseTypes.h:1012
InputParameters & operator=(const InputParameters &rhs)
void setDocUnit(const std::string &name, const std::string &doc_unit)
Set the unit string of a parameter.
std::map< std::string, std::pair< std::string, std::string > > getAutoBuildVectors() const
Returns the auto build vectors for all parameters.
std::string appendFunctorDescription(const std::string &doc_string) const
Appends description of what a functor is to a doc string.
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.
constexpr bool isMFEMFunctorNameTypeHelper(T *)
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
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::string & getObjectName() const
bool isControllable(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is controllable.
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::set< ExecFlagType > _controllable_flags
Controllable execute flag restriction.
void setCoupledVar(const std::string &coupling_name, const std::string &value)
Set a coupled variable parameter to a single variable name.
FRIEND_TEST(InputParametersTest, fileNames)
const hit::Node * _hit_node
Original location of parameter node; used for error messages.
void addCommandLineParam(const std::string &name, const std::string &syntax, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:345
char ** vars
std::unordered_map< std::string, std::string > _new_to_deprecated_coupled_vars
A map from deprecated coupled variable names to the new blessed name.
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...
FRIEND_TEST(InputParametersTest, commandLineParamSetNotCLParam)
InputParameters & operator+=(const InputParameters &rhs)
const std::set< std::string > & getCoupledVariableParamNames() const
Return the coupled variable parameter names.
bool isKokkosObject() const
Returns whether this InputParameters belongs to a Kokkos object Checks whether MooseBase::kokkos_obje...
ArgumentType argument_type
The type of argument.
std::optional< Moose::DataFileUtils::Path > _data_file_name_path
The searched path information pertaining to a DataFileName parameter.
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...
Class that is used as a parameter to setHitNode() that allows only relevant classes to set the hit no...
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 applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Method for applying common parameters.
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...
bool hasBase() const
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.
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 mooseError(Args &&... args) const
Emits an error prefixed with the object information, if available.
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.
void renameParameterGroup(const std::string &old_name, const std::string &new_name)
This method renames a parameter group.
std::set< std::string > _reserved_values
The reserved option names for a parameter.
void finalize(const std::string &parsing_syntax)
Finalizes the parameters, which must be done before constructing any objects with these parameters (t...
void addRequiredCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
Add parameters for retrieval from the command line.
const std::string & getBase() const
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Base class for actions.
Definition: Action.h:34
bool global
Whether or not the parameter is global (passed to MultiApps)
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...
This class wraps provides and tracks access to command line parameters.
Definition: CommandLine.h:29
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 * queryObjectType() const
const std::string & getDescription(const std::string &name) const
Get the documentation string for a parameter.
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available...
Structure for storing information about a command line parameter.
std::optional< std::pair< bool, std::string > > rangeCheck(const std::string &full_name, const std::string &short_name, const InputParameters::Parameter< T > &param, const bool include_param_path=true)
Runs a range on the supplied parameter if it exists and throws an error if that check fails...
bool isParamSetByAddParam(const std::string &name) const
Returns whether or not the parameter was set due to addParam.
void commandLineParamSet(const std::string &name, const CommandLineParamSetKey)
Marks the command line parameter name as set by the CommandLine.
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)
std::string syntax
The syntax for the parameter.
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
Class that is used as a parameter to commandLineParamSet() that allows only the CommandLine to set th...
std::string getDocUnit(const std::string &name) const
Returns the documentation unit string for the specified parameter name.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
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::pair< std::string, const hit::Node * > paramMessageContext(const std::string &param) const
Get the context associated with a parameter for a message.
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
The type for the callback to set RelationshipManager parameters.
Definition: MooseTypes.h:1038
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.
static constexpr bool isFunctorNameType()
std::string rawParamVal(const std::string &param) const
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
Specialized factory for generic Action System objects.
Definition: ActionFactory.h:48
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 trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
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)
FRIEND_TEST(InputParametersTest, fileNames)
std::string docstring(const std::string &desc)
Augment docstring if NEML2 is not enabled.
Definition: NEML2Utils.C:71
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:363
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...
std::string inputLocation(const std::string &param) const
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...
static const T & getParamHelper(const std::string &name, const InputParameters &pars)
std::string demangle(const char *name)
bool isMooseBaseObject() const
constexpr bool isFunctorNameTypeHelper(T *ex)
constexpr bool isScalarFunctorNameTypeHelper(T *)
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.
std::set< std::string > reservedValues(const std::string &name) const
Get a set of reserved parameter values.
Definition: Moose.h:46
SetParamHitNodeKey(const SetParamHitNodeKey &)
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.
std::optional< std::pair< bool, std::string > > parameterRangeCheck(const Parameters::Value &value, const std::string &long_name, const std::string &short_name, const bool include_param_path)
Performs a range check on the parameter (which must have a range check)
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
std::string paramMessagePrefix(const std::string &param) const
Get a prefix for messages associated with a parameter.
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)
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.
const std::string & getObjectType() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool isFinalized() const
void add_command_line_name(const std::string &name)
CommandLineParamSetKey(const CommandLineParamSetKey &)
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)
constexpr T * getNullptrExample()
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.
virtual ~InputParameters()=default
bool hasCoupledVar(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
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 paramLocationPrefix(const std::string &param) const
Returns a prefix containing the parameter name and location (if available)
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.
bool _finalized
Whether or not we&#39;ve called finalize() on these parameters yet.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
std::string blockFullpath() const
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") ...
class infix_ostream_iterator if void
Definition: InfixIterator.h:27
const hit::Node * _hit_node
The hit node representing the syntax that created these parameters, if any.
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...
std::optional< InputParameters::CommandLineMetadata > queryCommandLineMetadata(const std::string &name) const
bool isParamRequired(const std::string &name) const
Returns a boolean indicating whether the specified parameter is required or not.
std::string _doc_unit
The developer-designated unit of the parameter for use in documentation.
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 InputParameters::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 optional parameter and a documentation string to the InputParameters object...
bool _moose_object_syntax_visibility
This parameter hides derived MOOSE object types from appearing in syntax dumps.
SetHitNodeKey(const SetHitNodeKey &)
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.
void setHitNode(const std::string &param, const hit::Node &node, const SetParamHitNodeKey)
Sets the hit node associated with the parameter param to node.
const std::vector< VariableName > & getCoupledVar(const std::string &coupling_name) const
Get a coupled variable parameter.
bool _controllable
True if the parameters is controllable.
std::map< std::string, Metadata > _params
The actual parameter data.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
virtual void set_attributes(const std::string &name, bool inserted_only) override
Override from libMesh to set user-defined attributes on our parameter.
std::vector< std::string > switches
The switches for the parameter (i.e., [-t, –timing])
const T * queryParam(const std::string &name) const
Query a parameter.
std::string blockLocation() const
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 setHitNode(const hit::Node &node, const SetHitNodeKey)
Sets the hit node that represents the syntax responsible for creating these parameters.
std::optional< Moose::DataFileUtils::Path > queryDataFileNamePath(const std::string &name) const
void callMooseError(std::string msg, const bool with_prefix=true, const hit::Node *node=nullptr, const bool show_trace=true) const
Internal helper for calling back to mooseError(), ideally from the underlying MooseBase object if it ...
Parses MOOSE input using HIT/WASP.
Definition: Builder.h:56
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::filesystem::path getFileBase(const std::optional< std::string > &param_name=std::optional< std::string >()) const
std::vector< std::string > getVecMooseType(const std::string &name) const
const hit::Node * getHitNode() const
map_type::const_iterator const_iterator
std::optional< std::string > setupVariableNames(std::vector< VariableName > &names, const hit::Node &node, const Moose::PassKey< Moose::Builder >)
Entrypoint for the Builder to setup a std::vector<VariableName> parameter, which will setup the defau...
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
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
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 paramFullpath(const std::string &param) const
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
Class for parsing input files.
Definition: Parser.h:87
Class that is used as a parameter to setHitNode(param) that allows only relevant classes to set the h...
std::string _group
The names of the parameters organized into groups.
void addOptionalValuedCommandLineParam(const std::string &name, const std::string &syntax, const T &value, const std::string &doc_string)
Add a command line parameter with an optional value.
void applyCommonUserSetParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Variant of applyParameters that only applies parameters explicitly set by the user in common (i...
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.