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 hasCoupledValue(const std::string & coupling_name) const;
919 
925  bool hasDefaultCoupledValue(const std::string & coupling_name) const;
926 
933  Real defaultCoupledValue(const std::string & coupling_name, unsigned int i = 0) const;
934 
940  unsigned int numberDefaultCoupledValues(const std::string & coupling_name) const;
941 
949  void defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i = 0);
950 
954  std::map<std::string, std::pair<std::string, std::string>> getAutoBuildVectors() const;
955 
956  // BEGIN APPLY PARAMETER METHODS
974  void applyParameters(const InputParameters & common,
975  const std::vector<std::string> & exclude = {},
976  const bool allow_private = false);
977 
983  void applyCommonUserSetParameters(const InputParameters & common,
984  const std::vector<std::string> & exclude = {},
985  const bool allow_private = false);
986 
1004  void applySpecificParameters(const InputParameters & common,
1005  const std::vector<std::string> & include,
1006  bool allow_private = false);
1007 
1019  void applyParameter(const InputParameters & common,
1020  const std::string & common_name,
1021  bool allow_private = false);
1022  // END APPLY PARAMETER METHODS
1023 
1034  void applyCoupledVar(const InputParameters & common, const std::string & var_name);
1035 
1039  bool paramSetByUser(const std::string & name) const;
1040 
1045  bool isParamSetByUser(const std::string & name) const;
1046 
1052  bool isParamDefined(const std::string & name) const;
1053 
1062  template <typename T>
1063  const T * queryParam(const std::string & name) const;
1064 
1066  /*
1067  * These methods are here to retrieve parameters for scalar and vector types respectively. We will
1068  * throw errors
1069  * when returning most scalar and vector types.
1070  */
1071  template <typename T>
1072  static const T & getParamHelper(const std::string & name, const InputParameters & pars);
1074 
1075  using Parameters::get;
1076 
1078  template <typename R1,
1079  typename R2,
1080  typename V1 = typename std::conditional<std::is_same<R1, MooseEnumItem>::value,
1082  std::vector<R1>>::type,
1083  typename V2 = typename std::conditional<std::is_same<R2, MooseEnumItem>::value,
1085  std::vector<R2>>::type>
1086  std::vector<std::pair<R1, R2>> get(const std::string & param1, const std::string & param2) const;
1087 
1091  std::set<std::string> getParametersList() const;
1092 
1096  std::set<std::string> getControllableParameters() const;
1097 
1101  std::set<std::string> getGroupParameters(const std::string & group) const;
1102 
1107  void setReservedValues(const std::string & name, const std::set<std::string> & reserved);
1108 
1113  std::set<std::string> reservedValues(const std::string & name) const;
1114 
1119  std::string blockLocation() const;
1120 
1125  std::string blockFullpath() const;
1126 
1130  const hit::Node * getHitNode(const std::string & param) const;
1136  void setHitNode(const std::string & param, const hit::Node & node, const SetParamHitNodeKey);
1137 
1142  std::string inputLocation(const std::string & param) const;
1143 
1148  std::string paramFullpath(const std::string & param) const;
1149 
1153  std::string paramLocationPrefix(const std::string & param) const;
1154 
1162  template <typename... Args>
1163  std::string paramMessage(const std::string & param, Args... args) const;
1164 
1168  template <typename... Args>
1169  [[noreturn]] void mooseError(Args &&... args) const;
1170 
1175  template <typename... Args>
1176  [[noreturn]] void paramError(const std::string & param, Args... args) const;
1177 
1182  std::string rawParamVal(const std::string & param) const;
1183 
1188  template <typename T>
1189  void ignoreParameter(const std::string & name);
1190 
1195  bool shouldIgnore(const std::string & name);
1196 
1200  template <typename T>
1201  bool isType(const std::string & name) const;
1202 
1209  std::string varName(const std::string & var_param_name,
1210  const std::string & moose_object_with_var_param_name) const;
1211 
1219  void renameParam(const std::string & old_name,
1220  const std::string & new_name,
1221  const std::string & new_docstring);
1222 
1229  void renameCoupledVar(const std::string & old_name,
1230  const std::string & new_name,
1231  const std::string & new_docstring);
1232 
1233  void deprecateParam(const std::string & old_name,
1234  const std::string & new_name,
1235  const std::string & removal_date);
1236 
1237  void deprecateCoupledVar(const std::string & old_name,
1238  const std::string & new_name,
1239  const std::string & removal_date);
1240 
1247  std::string checkForRename(const std::string & name) const;
1248 
1255  template <typename T>
1256  const T & get(std::string_view name) const;
1257 
1266  template <typename T>
1267  bool have_parameter(std::string_view name) const;
1268 
1276  template <typename T>
1277  void transferParam(const InputParameters & source_param,
1278  const std::string & name,
1279  const std::string & new_name = "",
1280  const std::string & new_description = "");
1281 
1294  std::vector<std::string> paramAliases(const std::string & param_name) const;
1295 
1300  const hit::Node * getHitNode() const { return _hit_node; }
1308  void setHitNode(const hit::Node & node, const SetHitNodeKey) { _hit_node = &node; }
1309 
1313  bool isFinalized() const { return _finalized; }
1314 
1318  std::optional<Moose::DataFileUtils::Path> queryDataFileNamePath(const std::string & name) const;
1319 
1328  std::optional<std::string> setupVariableNames(std::vector<VariableName> & names,
1329  const hit::Node & node,
1331 
1332 private:
1333  // Private constructor so that InputParameters can only be created in certain places.
1334  InputParameters();
1335 
1339  void setParameters() {}
1340 
1341  template <typename T>
1342  static constexpr bool isFunctorNameType();
1343 
1347  template <typename T>
1348  std::string appendFunctorDescription(const std::string & doc_string) const;
1349 
1353  void setDeprecatedVarDocString(const std::string & new_name, const std::string & doc_string);
1354 
1355  void renameParamInternal(const std::string & old_name,
1356  const std::string & new_name,
1357  const std::string & docstring,
1358  const std::string & removal_date);
1359 
1360  void renameCoupledVarInternal(const std::string & old_name,
1361  const std::string & new_name,
1362  const std::string & docstring,
1363  const std::string & removal_date);
1364 
1371  std::pair<std::string, const hit::Node *> paramMessageContext(const std::string & param) const;
1377  std::string paramMessagePrefix(const std::string & param) const;
1378 
1379  struct Metadata
1380  {
1381  std::string _doc_string;
1383  std::string _doc_unit;
1385  std::string _custom_type;
1387  std::optional<CommandLineMetadata> _cl_data;
1389  std::optional<Moose::DataFileUtils::Path> _data_file_name_path;
1391  std::string _group;
1393  std::string _range_function;
1395  std::pair<std::string, std::string> _autobuild_vecs;
1397  bool _required = false;
1403  bool _valid = false;
1405  bool _is_private = false;
1408  std::vector<Real> _coupled_default = {0};
1410  bool _set_by_add_param = false;
1412  std::set<std::string> _reserved_values;
1416  const hit::Node * _hit_node;
1418  bool _controllable = false;
1420  std::set<ExecFlagType> _controllable_flags;
1422  bool _ignore = false;
1423  };
1424 
1425  Metadata & at(const std::string & param_name)
1426  {
1427  const auto param = checkForRename(param_name);
1428  if (_params.count(param) == 0)
1429  mooseError("param '", param, "' not present in InputParams");
1430  return _params[param];
1431  }
1432  const Metadata & at(const std::string & param_name) const
1433  {
1434  const auto param = checkForRename(param_name);
1435  if (_params.count(param) == 0)
1436  mooseError("param '", param, "' not present in InputParams");
1437  return _params.at(param);
1438  }
1439 
1450 
1454  void checkParamName(const std::string & name) const;
1455 
1460  template <typename T, typename S>
1461  void setParamHelper(const std::string & name, T & l_value, const S & r_value);
1462 
1471  template <typename T>
1472  void addCommandLineParamHelper(const std::string & name,
1473  const std::string & syntax,
1474  const bool required,
1475  const bool value_required);
1476 
1481  [[noreturn]] void callMooseError(std::string msg,
1482  const bool with_prefix = true,
1483  const hit::Node * node = nullptr,
1484  const bool show_trace = true) const;
1485 
1488  std::map<std::string, Metadata> _params;
1489 
1491  std::set<std::string> _coupled_vars;
1492 
1495  std::string _class_description;
1496 
1499  std::vector<std::string> _buildable_types;
1500 
1505  std::vector<std::tuple<std::string,
1509 
1513 
1516 
1520 
1523 
1525  std::unordered_map<std::string, std::string> _new_to_deprecated_coupled_vars;
1526 
1531  std::map<std::string, std::pair<std::string, std::string>> _old_to_new_name_and_dep;
1532 
1535  std::multimap<std::string, std::string> _new_to_old_names;
1536 
1538  const hit::Node * _hit_node;
1539 
1542 
1543  // These are the only objects allowed to _create_ InputParameters
1546  friend class Parser;
1547  // for the printInputFile function in the action warehouse
1548  friend class ActionWarehouse;
1549 };
1550 
1551 template <typename T>
1552 void
1553 InputParameters::setHelper(const std::string & /*name*/)
1554 {
1555 }
1556 
1557 // Template and inline function implementations
1558 template <typename T>
1559 T &
1560 InputParameters::set(const std::string & name_in, bool quiet_mode)
1561 {
1562  const auto name = checkForRename(name_in);
1563 
1565  checkConsistentType<T>(name);
1566 
1567  T & result = this->Parameters::set<T>(name);
1568 
1569  if (quiet_mode)
1570  _params[name]._set_by_add_param = true;
1571 
1572  setHelper<T>(name);
1573 
1574  return result;
1575 }
1576 
1577 template <typename T, typename... Ts>
1578 void
1579 InputParameters::setParameters(const std::string & name,
1580  const T & value,
1581  Ts... extra_input_parameters)
1582 {
1583  this->set<T>(name) = value;
1584  this->setParameters(extra_input_parameters...);
1585 }
1586 
1587 template <typename T, typename UP_T>
1588 std::optional<std::pair<bool, std::string>>
1589 InputParameters::rangeCheck(const std::string & full_name,
1590  const std::string & short_name,
1591  const InputParameters::Parameter<std::vector<T>> & param,
1592  const bool include_param_path)
1593 {
1594  if (!isParamValid(short_name))
1595  return {};
1596 
1597  const auto & range_function = _params[short_name]._range_function;
1598  if (range_function.empty())
1599  return {};
1600 
1613  std::vector<std::string> vars;
1614  if (fp.ParseAndDeduceVariables(range_function, vars) != -1) // -1 for success
1615  return {{false,
1616  "Error parsing expression '" + range_function + "' for parameter " + short_name + ""}};
1617 
1618  // Fparser parameter buffer
1619  std::vector<UP_T> parbuf(vars.size());
1620 
1621  // parameter vector
1622  const std::vector<T> & value = param.get();
1623 
1624  // iterate over all vector values (maybe ;)
1625  bool need_to_iterate = false;
1626  unsigned int i = 0;
1627  do
1628  {
1629  // set parameters
1630  for (unsigned int j = 0; j < vars.size(); j++)
1631  {
1632  if (vars[j] == short_name)
1633  {
1634  if (value.size() == 0)
1635  {
1636  std::ostringstream oss;
1637  oss << "Range checking empty vector";
1638  if (include_param_path)
1639  oss << " parameter " << full_name;
1640  oss << "; expression = '" << range_function << "'";
1641  return {{true, oss.str()}};
1642  }
1643 
1644  parbuf[j] = value[i];
1645  need_to_iterate = true;
1646  }
1647  else if (vars[j] == short_name + "_size")
1648  parbuf[j] = value.size();
1649  else
1650  {
1651  if (vars[j].substr(0, short_name.size() + 1) != short_name + "_")
1652  return {{false, "Error parsing expression '" + range_function + "'"}};
1653  std::istringstream iss(vars[j]);
1654  iss.seekg(short_name.size() + 1);
1655 
1656  size_t index;
1657  if (iss >> index && iss.eof())
1658  {
1659  if (index >= value.size())
1660  {
1661  std::ostringstream oss;
1662  oss << "Error parsing expression '" + range_function + "'";
1663  if (include_param_path)
1664  oss << " for parameter " << full_name;
1665  oss << "; out of range variable '" + vars[j] << "'";
1666  return {{true, oss.str()}};
1667  }
1668  parbuf[j] = value[index];
1669  }
1670  else
1671  return {{false,
1672  "Error parsing expression '" + range_function + "'; invalid variable '" +
1673  vars[j] + "'"}};
1674  }
1675  }
1676 
1677  // ensure range-checked input file parameter comparison functions
1678  // do absolute floating point comparisons instead of using a default epsilon.
1679  auto tmp_eps = fp.epsilon();
1680  fp.setEpsilon(0);
1681  UP_T result = fp.Eval(&parbuf[0]);
1682  fp.setEpsilon(tmp_eps);
1683 
1684  // test function using the parameters determined above
1685  if (fp.EvalError())
1686  return {{false, "Error evaluating expression '" + range_function + "'"}};
1687 
1688  if (!result)
1689  {
1690  std::ostringstream oss;
1691  oss << "Range check failed";
1692  if (include_param_path)
1693  oss << " for parameter " << full_name;
1694  oss << "; expression = '" << range_function << "'";
1695  if (need_to_iterate)
1696  oss << ", component " << i;
1697  return {{true, oss.str()}};
1698  }
1699 
1700  } while (need_to_iterate && ++i < value.size());
1701 
1702  return {};
1703 }
1704 
1705 template <typename T, typename UP_T>
1706 std::optional<std::pair<bool, std::string>>
1707 InputParameters::rangeCheck(const std::string & full_name,
1708  const std::string & short_name,
1709  const InputParameters::Parameter<T> & param,
1710  const bool include_param_path)
1711 {
1712  if (!isParamValid(short_name))
1713  return {};
1714 
1715  const auto & range_function = _params[short_name]._range_function;
1716  if (range_function.empty())
1717  return {};
1718 
1719  // Parse the expression
1721  if (fp.Parse(range_function, short_name) != -1) // -1 for success
1722  return {{false,
1723  "Error parsing expression '" + range_function + "'" + " for parameter " + short_name}};
1724 
1725  // ensure range-checked input file parameter comparison functions
1726  // do absolute floating point comparisons instead of using a default epsilon.
1727  auto tmp_eps = fp.epsilon();
1728  fp.setEpsilon(0);
1729  // We require a non-const value for the implicit upscaling of the parameter type
1730  std::vector<UP_T> value(1, param.get());
1731  UP_T result = fp.Eval(&value[0]);
1732  fp.setEpsilon(tmp_eps);
1733 
1734  if (fp.EvalError())
1735  return {{true,
1736  "Error evaluating expression '" + range_function + "' for parameter " + short_name +
1737  "; perhaps you used the wrong variable name?"}};
1738 
1739  if (!result)
1740  {
1741  std::ostringstream oss;
1742  oss << "Range check failed";
1743  if (include_param_path)
1744  oss << " for parameter " << full_name;
1745  oss << "; expression = '" << range_function << "', value = " << value[0];
1746  return {{true, oss.str()}};
1747  }
1748 
1749  return {};
1750 }
1751 
1752 template <typename T>
1753 T
1754 InputParameters::getCheckedPointerParam(const std::string & name_in,
1755  const std::string & error_string) const
1756 {
1757  const auto name = checkForRename(name_in);
1758 
1759  T param = this->get<T>(name);
1760 
1761  // Note: You will receive a compile error on this line if you attempt to pass a non-pointer
1762  // template type to this method
1763  if (!param)
1764  mooseError("Parameter ", name, " is NULL.\n", error_string);
1765  return this->get<T>(name);
1766 }
1767 
1768 template <typename T>
1769 void
1770 InputParameters::addRequiredParam(const std::string & name, const std::string & doc_string)
1771 {
1773  checkConsistentType<T>(name);
1774 
1775  InputParameters::insert<T>(name);
1776  auto & metadata = _params[name];
1777  metadata._required = true;
1778  if constexpr (isFunctorNameType<T>())
1779  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1780  else
1781  metadata._doc_string = doc_string;
1782 }
1783 
1784 template <typename T>
1785 void
1786 InputParameters::addRequiredParam(const std::string & /*name*/,
1787  const T & /*value*/,
1788  const std::string & /*doc_string*/)
1789 {
1790  mooseError("You cannot call addRequiredParam and supply a default value for this type, please "
1791  "use addParam instead");
1792 }
1793 
1794 template <typename T, typename S>
1795 void
1796 InputParameters::addParam(const std::string & name, const S & value, const std::string & doc_string)
1797 {
1799  checkConsistentType<T>(name);
1800 
1801  T & l_value = InputParameters::set<T>(name);
1802  auto & metadata = _params[name];
1803  if constexpr (isFunctorNameType<T>())
1804  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1805  else
1806  metadata._doc_string = doc_string;
1807 
1808  // Set the parameter now
1809  setParamHelper(name, l_value, value);
1810 
1811  /* Indicate the default value, as set via addParam, is being used. The parameter is removed from
1812  the list whenever
1813  it changes, see set_attributes */
1814  metadata._set_by_add_param = true;
1815 }
1816 
1817 template <typename T>
1818 void
1819 InputParameters::addParam(const std::string & name, const std::string & doc_string)
1820 {
1822  checkConsistentType<T>(name);
1823 
1824  InputParameters::insert<T>(name);
1825  if constexpr (isFunctorNameType<T>())
1826  _params[name]._doc_string = appendFunctorDescription<T>(doc_string);
1827  else
1828  _params[name]._doc_string = doc_string;
1829 }
1830 
1831 template <typename T, typename S>
1832 void
1833 InputParameters::setParamHelper(const std::string & /*name*/, T & l_value, const S & r_value)
1834 {
1835  l_value = r_value;
1836 }
1837 
1838 template <typename T>
1839 void
1841  const std::string & syntax,
1842  const bool required,
1843  const bool value_required)
1844 {
1845  static_assert(isValidCommandLineType<T>::value,
1846  "This type is not a supported command line parameter type. See "
1847  "CommandLine::populateCommandLineParams to add it as a supported type.");
1848 
1849  auto & cl_data = at(name)._cl_data;
1850  cl_data = CommandLineMetadata();
1851 
1852  // Split up the syntax by whitespace
1853  std::vector<std::string> syntax_split;
1854  MooseUtils::tokenize(syntax, syntax_split, 1, " \t\n\v\f\r");
1855 
1856  // Set the single syntax string as the combined syntax with removed whitespace
1857  cl_data->syntax = MooseUtils::stringJoin(syntax_split);
1858  mooseAssert(cl_data->syntax.size(), "Empty token");
1859 
1860  // Set the switches; only parse those that begin with "-" as we also
1861  // provide examples within the syntax
1862  for (const auto & val : syntax_split)
1863  if (val.rfind("-", 0) == 0)
1864  {
1865  if (!std::regex_search(val, std::regex("^\\-+[a-zA-Z]")))
1866  mooseError("The switch '",
1867  val,
1868  "' for the command line parameter '",
1869  name,
1870  "' is invalid. It must begin with an alphabetical character.");
1871 
1872  cl_data->switches.push_back(val);
1874  }
1875 
1876  cl_data->required = required;
1877  cl_data->global = false;
1878 
1879  // No arguments needed for a boolean parameter
1880  if constexpr (std::is_same_v<T, bool>)
1881  {
1882  (void)value_required; // purposely unused; doesn't take a value
1883  cl_data->argument_type = CommandLineMetadata::ArgumentType::NONE;
1884  }
1885  // MooseEnums require a value
1886  else if constexpr (std::is_same_v<T, MooseEnum>)
1887  {
1888  (void)value_required; // purposely unused; always required
1889  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1890  }
1891  // The user didn't specify a default, so a value is required
1892  else if (value_required)
1893  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1894  // Otherwise, it's optional (user specified a default)
1895  else
1896  cl_data->argument_type = CommandLineMetadata::ArgumentType::OPTIONAL;
1897 }
1898 
1899 template <typename T>
1900 void
1902  const std::string & parsed_function,
1903  const std::string & doc_string)
1904 {
1905  addRequiredParam<T>(name, doc_string);
1906  _params[name]._range_function = parsed_function;
1907 }
1908 
1909 template <typename T>
1910 void
1911 InputParameters::addRangeCheckedParam(const std::string & name,
1912  const T & value,
1913  const std::string & parsed_function,
1914  const std::string & doc_string)
1915 {
1916  addParam<T>(name, value, doc_string);
1917  _params[name]._range_function = parsed_function;
1918 }
1919 
1920 template <typename T>
1921 void
1922 InputParameters::addRangeCheckedParam(const std::string & name,
1923  const std::string & parsed_function,
1924  const std::string & doc_string)
1925 {
1926  addParam<T>(name, doc_string);
1927  _params[name]._range_function = parsed_function;
1928 }
1929 
1930 template <typename T>
1931 void
1933  const std::string & custom_type,
1934  const std::string & doc_string)
1935 {
1936  addRequiredParam<T>(name, doc_string);
1937  _params[name]._custom_type = custom_type;
1938 }
1939 
1940 template <typename T>
1941 void
1942 InputParameters::addCustomTypeParam(const std::string & name,
1943  const T & value,
1944  const std::string & custom_type,
1945  const std::string & doc_string)
1946 {
1947  addParam<T>(name, value, doc_string);
1948  _params[name]._custom_type = custom_type;
1949 }
1950 
1951 template <typename T>
1952 void
1953 InputParameters::addCustomTypeParam(const std::string & name,
1954  const std::string & custom_type,
1955  const std::string & doc_string)
1956 {
1957  addParam<T>(name, doc_string);
1958  _params[name]._custom_type = custom_type;
1959 }
1960 
1961 template <typename T>
1962 void
1964  const std::string & custom_type,
1965  const std::string & doc_string,
1966  const std::string & deprecation_message)
1967 {
1968  _show_deprecated_message = false;
1969  addParam<T>(name, doc_string);
1970  auto & metadata = _params[name];
1971  metadata._custom_type = custom_type;
1972 
1973  metadata._deprecation_message = deprecation_message;
1974  _show_deprecated_message = true;
1975 }
1976 
1977 template <typename T>
1978 void
1979 InputParameters::addPrivateParam(const std::string & name)
1980 {
1982  checkConsistentType<T>(name);
1983 
1984  InputParameters::insert<T>(name);
1985  _params[name]._is_private = true;
1986 }
1987 
1988 template <typename T>
1989 void
1990 InputParameters::addPrivateParam(const std::string & name, const T & value)
1991 {
1993  checkConsistentType<T>(name);
1994 
1995  InputParameters::set<T>(name) = value;
1996  auto & metadata = _params[name];
1997  metadata._is_private = true;
1998  metadata._set_by_add_param = true;
1999 }
2000 
2001 template <typename T>
2002 void
2004  const std::string & syntax,
2005  const std::string & doc_string)
2006 {
2007  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool");
2008 
2009  addRequiredParam<T>(name, doc_string);
2010  addCommandLineParamHelper<T>(name, syntax, /* required = */ true, /* value_required = */ true);
2011 }
2012 
2013 template <typename T>
2014 void
2015 InputParameters::addCommandLineParam(const std::string & name,
2016  const std::string & syntax,
2017  const std::string & doc_string)
2018 {
2019  static_assert(!std::is_same_v<T, MooseEnum>,
2020  "addCommandLineParam() without a value cannot be used with a MooseEnum because a "
2021  "MooseEnum requires initialization");
2022 
2023  auto constexpr is_bool = std::is_same_v<T, bool>;
2024  if constexpr (is_bool)
2025  addParam<T>(name, false, doc_string);
2026  else
2027  addParam<T>(name, doc_string);
2028 
2029  addCommandLineParamHelper<T>(
2030  name, syntax, /* required = */ false, /* value_required = */ !is_bool);
2031 }
2032 
2033 template <typename T>
2034 void
2035 InputParameters::addCommandLineParam(const std::string & name,
2036  const std::string & syntax,
2037  const T & value,
2038  const std::string & doc_string)
2039 {
2040  if constexpr (std::is_same_v<T, bool>)
2041  mooseAssert(!value, "Default for bool must be false");
2042 
2043  addParam<T>(name, value, doc_string);
2044  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ true);
2045 }
2046 
2047 template <typename T>
2048 void
2050  const std::string & syntax,
2051  const T & value,
2052  const std::string & doc_string)
2053 {
2054  mooseAssert(name == "csg_only" || name == "mesh_only" || name == "recover" || name == "run",
2055  "Not supported for new parameters");
2056  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool (does not take a value)");
2057  addParam<T>(name, value, doc_string);
2058  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ false);
2059 }
2060 
2061 template <typename T>
2062 void
2063 InputParameters::checkConsistentType(const std::string & name_in) const
2064 {
2065  const auto name = checkForRename(name_in);
2066 
2067  // If we don't currently have the Parameter, can't be any inconsistency
2069  if (it == _values.end())
2070  return;
2071 
2072  // Now, if we already have the Parameter, but it doesn't have the
2073  // right type, throw an error.
2074  if (!this->Parameters::have_parameter<T>(name))
2075  mooseError("Attempting to set parameter \"",
2076  name,
2077  "\" with type (",
2078  libMesh::demangle(typeid(T).name()),
2079  ")\nbut the parameter already exists as type (",
2080  it->second->type(),
2081  ")");
2082 }
2083 
2084 template <typename T>
2085 void
2086 InputParameters::suppressParameter(const std::string & name_in)
2087 {
2088  const auto name = checkForRename(name_in);
2089  if (!this->have_parameter<T>(name))
2090  mooseError("Unable to suppress nonexistent parameter: ", name);
2091 
2092  auto & metadata = _params[name];
2093  metadata._required = false;
2094  metadata._is_private = true;
2095  metadata._controllable = false;
2096 }
2097 
2098 template <typename T>
2099 void
2100 InputParameters::ignoreParameter(const std::string & name_in)
2101 {
2102  const auto name = checkForRename(name_in);
2103  suppressParameter<T>(name);
2104  _params[name]._ignore = true;
2105 }
2106 
2107 template <typename T>
2108 void
2109 InputParameters::makeParamRequired(const std::string & name_in)
2110 {
2111  const auto name = checkForRename(name_in);
2112 
2113  if (!this->have_parameter<T>(name))
2114  mooseError("Unable to require nonexistent parameter: ", name);
2115 
2116  _params[name]._required = true;
2117 }
2118 
2119 template <typename T>
2120 void
2121 InputParameters::makeParamNotRequired(const std::string & name_in)
2122 {
2123  const auto name = checkForRename(name_in);
2124 
2125  if (!this->have_parameter<T>(name))
2126  mooseError("Unable to un-require nonexistent parameter: ", name);
2127 
2128  _params[name]._required = false;
2129 }
2130 
2131 template <typename T>
2132 void
2133 InputParameters::addDeprecatedParam(const std::string & name,
2134  const T & value,
2135  const std::string & doc_string,
2136  const std::string & deprecation_message)
2137 {
2138  _show_deprecated_message = false;
2139  mooseAssert(!_old_to_new_name_and_dep.count(name),
2140  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2141  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2142  addParam<T>(name, value, doc_string);
2143 
2144  _params[name]._deprecation_message = deprecation_message;
2145  _show_deprecated_message = true;
2146 }
2147 
2148 template <typename T>
2149 void
2150 InputParameters::addDeprecatedParam(const std::string & name,
2151  const std::string & doc_string,
2152  const std::string & deprecation_message)
2153 {
2154  _show_deprecated_message = false;
2155  mooseAssert(!_old_to_new_name_and_dep.count(name),
2156  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2157  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2158  addParam<T>(name, doc_string);
2159 
2160  _params[name]._deprecation_message = deprecation_message;
2161  _show_deprecated_message = true;
2162 }
2163 
2164 // Forward declare MooseEnum specializations for add*Param
2165 template <>
2166 void InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
2167  const MooseEnum & moose_enum,
2168  const std::string & doc_string);
2169 
2170 template <>
2171 void InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
2172  const MultiMooseEnum & moose_enum,
2173  const std::string & doc_string);
2174 
2175 template <>
2176 void InputParameters::addRequiredParam<std::vector<MooseEnum>>(
2177  const std::string & name,
2178  const std::vector<MooseEnum> & moose_enums,
2179  const std::string & doc_string);
2180 
2181 template <>
2182 void InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
2183  const std::string & name,
2184  const std::vector<MultiMooseEnum> & moose_enums,
2185  const std::string & doc_string);
2186 
2187 template <>
2188 void InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
2189  const std::string & /*doc_string*/);
2190 
2191 template <>
2192 void InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
2193  const std::string & /*doc_string*/);
2194 
2195 template <>
2196 void InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
2197  const std::string & /*doc_string*/);
2198 
2199 template <>
2200 void InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2201  const std::string & /*doc_string*/);
2202 
2203 template <>
2204 void
2205 InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2206  const std::string & /*doc_string*/);
2207 
2208 template <>
2209 void InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/);
2210 
2211 template <>
2212 void InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/);
2213 
2214 template <>
2215 void InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
2216  const std::string & /*doc_string*/,
2217  const std::string & /*deprecation_message*/);
2218 
2219 template <>
2220 void
2221 InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
2222  const std::string & /*doc_string*/,
2223  const std::string & /*deprecation_message*/);
2224 
2225 template <>
2226 void InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
2227  const std::string & /*name*/,
2228  const std::string & /*doc_string*/,
2229  const std::string & /*deprecation_message*/);
2230 
2231 // Forward declare specializations for setParamHelper
2232 template <>
2233 void InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & name,
2234  PostprocessorName & l_value,
2235  const Real & r_value);
2236 
2237 template <>
2238 void InputParameters::setParamHelper<PostprocessorName, int>(const std::string & name,
2239  PostprocessorName & l_value,
2240  const int & r_value);
2241 
2242 template <>
2243 void InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
2244  FunctionName & l_value,
2245  const Real & r_value);
2246 
2247 template <>
2248 void InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
2249  FunctionName & l_value,
2250  const int & r_value);
2251 
2252 template <>
2253 void InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
2254  MaterialPropertyName & l_value,
2255  const Real & r_value);
2256 
2257 template <>
2258 void InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
2259  MaterialPropertyName & l_value,
2260  const int & r_value);
2261 
2262 template <>
2263 void InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
2264  MooseFunctorName & l_value,
2265  const Real & r_value);
2266 
2267 template <>
2268 void InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
2269  MooseFunctorName & l_value,
2270  const int & r_value);
2271 
2272 template <typename T>
2273 const T *
2274 InputParameters::queryParam(const std::string & name) const
2275 {
2276  return isParamValid(name) ? &getParamHelper<T>(name, *this) : nullptr;
2277 }
2278 
2279 template <typename T>
2280 const T &
2281 InputParameters::getParamHelper(const std::string & name_in, const InputParameters & pars)
2282 {
2283  const auto name = pars.checkForRename(name_in);
2284 
2285  if (!pars.isParamValid(name))
2286  pars.mooseError("The parameter \"", name, "\" is being retrieved before being set.");
2287 
2288  return pars.get<T>(name);
2289 }
2290 
2291 // Declare specializations so we don't fall back on the generic
2292 // implementation, but the definition will be in InputParameters.C so
2293 // we won't need to bring in *MooseEnum header files here.
2294 template <>
2295 const MooseEnum & InputParameters::getParamHelper<MooseEnum>(const std::string & name,
2296  const InputParameters & pars);
2297 
2298 template <>
2299 const MultiMooseEnum &
2300 InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name,
2301  const InputParameters & pars);
2302 
2303 template <typename R1, typename R2, typename V1, typename V2>
2304 std::vector<std::pair<R1, R2>>
2305 InputParameters::get(const std::string & param1_in, const std::string & param2_in) const
2306 {
2307  const auto param1 = checkForRename(param1_in);
2308  const auto param2 = checkForRename(param2_in);
2309 
2310  const auto & v1 = get<V1>(param1);
2311  const auto & v2 = get<V2>(param2);
2312 
2313  auto controllable = getControllableParameters();
2314  if (controllable.count(param1) || controllable.count(param2))
2315  mooseError("Parameters ",
2316  param1,
2317  " and/or ",
2318  param2 + " are controllable parameters and cannot be retireved using "
2319  "the MooseObject::getParam/InputParameters::get methods for pairs");
2320 
2321  if (v1.size() != v2.size())
2322  paramError(param1,
2323  "Vector parameters ",
2324  param1,
2325  "(size: ",
2326  v1.size(),
2327  ") and " + param2,
2328  "(size: ",
2329  v2.size(),
2330  ") are of different lengths \n");
2331 
2332  std::vector<std::pair<R1, R2>> parameter_pairs;
2333  auto i1 = v1.begin();
2334  auto i2 = v2.begin();
2335  for (; i1 != v1.end() && i2 != v2.end(); ++i1, ++i2)
2336  parameter_pairs.emplace_back(std::make_pair(*i1, *i2));
2337  return parameter_pairs;
2338 }
2339 
2341 
2342 template <typename T>
2343 bool
2344 InputParameters::isType(const std::string & name_in) const
2345 {
2346  const auto name = checkForRename(name_in);
2347 
2348  if (!_params.count(name))
2349  mooseError("Parameter \"", name, "\" is not valid.");
2350  return have_parameter<T>(name);
2351 }
2352 
2353 template <typename T>
2354 const T &
2355 InputParameters::get(std::string_view name_in) const
2356 {
2357  const auto name = checkForRename(std::string(name_in));
2358 
2359  return Parameters::get<T>(name);
2360 }
2361 
2362 template <typename T>
2363 bool
2364 InputParameters::have_parameter(std::string_view name_in) const
2365 {
2366  const auto name = checkForRename(std::string(name_in));
2367 
2368  return Parameters::have_parameter<T>(name);
2369 }
2370 
2371 template <typename T>
2372 void
2374  const std::string & name_in,
2375  const std::string & new_name,
2376  const std::string & new_description)
2377 {
2378  const auto name = source_params.checkForRename(std::string(name_in));
2379  const auto p_name = new_name.empty() ? name_in : new_name;
2380  if (!source_params.have_parameter<T>(name) && !source_params.hasCoupledValue(name))
2381  mooseError("The '",
2382  name_in,
2383  "' parameter could not be transferred because it does not exist with type '",
2384  MooseUtils::prettyCppType<T>(),
2385  "' in the source parameters");
2386  if (name != name_in)
2387  mooseWarning("The transferred parameter " + name_in + " is deprecated in favor of " + name +
2388  " in the source parameters. The new name should likely be used for the parameter "
2389  "transfer instead.");
2390  const std::string description =
2391  new_description.empty() ? source_params.getDescription(name) : new_description;
2392 
2393  if (source_params.isParamRequired(name))
2394  {
2395  // Check for a variable parameter
2396  if (source_params.hasCoupledValue(name))
2397  addRequiredCoupledVar(p_name, description);
2398  // Enums parameters have a default list of options
2399  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2400  addRequiredParam<T>(p_name, source_params.get<T>(name), description);
2401  else if (source_params.isRangeChecked(name))
2402  addRequiredRangeCheckedParam<T>(
2403  p_name, source_params.rangeCheckedFunction(name), description);
2404  else
2405  addRequiredParam<T>(p_name, description);
2406  }
2407  else
2408  {
2409  // Check for a variable parameter
2410  if (source_params.hasCoupledValue(name))
2411  {
2412  if (!source_params.hasDefaultCoupledValue(name))
2413  addCoupledVar(p_name, description);
2414  else if (source_params.numberDefaultCoupledValues(name) == 1)
2415  addCoupledVar(p_name, source_params.defaultCoupledValue(name), description);
2416  else
2417  {
2418  std::vector<Real> coupled_values;
2419  for (const auto i : libMesh::make_range(source_params.numberDefaultCoupledValues(name)))
2420  coupled_values.push_back(source_params.defaultCoupledValue(name, i));
2421  addCoupledVar(p_name, coupled_values, description);
2422  }
2423  }
2424  else if (source_params.isRangeChecked(name))
2425  {
2426  if (source_params.hasDefault(name))
2427  addRangeCheckedParam<T>(p_name,
2428  source_params.get<T>(name),
2429  source_params.rangeCheckedFunction(name),
2430  description);
2431  else
2432  addRangeCheckedParam<T>(p_name, source_params.rangeCheckedFunction(name), description);
2433  }
2434  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2435  addParam<T>(p_name, source_params.get<T>(name), description);
2436  else
2437  {
2438  if (source_params.hasDefault(name))
2439  addParam<T>(p_name, source_params.get<T>(name), description);
2440  else
2441  addParam<T>(p_name, description);
2442  }
2443  }
2444 
2445  // Copy other attributes
2446  if (source_params.isPrivate(name))
2447  _params[p_name]._is_private = true;
2448  if (source_params.isControllable(name))
2449  _params[p_name]._controllable = true;
2450 }
2451 
2452 template <typename... Args>
2453 [[noreturn]] void
2454 InputParameters::mooseError(Args &&... args) const
2455 {
2456  std::ostringstream oss;
2457  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2458  callMooseError(oss.str());
2459 }
2460 
2461 template <typename... Args>
2462 std::string
2463 InputParameters::paramMessage(const std::string & param, Args... args) const
2464 {
2465  std::ostringstream oss;
2466  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2467  return paramMessagePrefix(param) + oss.str();
2468 }
2469 
2470 template <typename... Args>
2471 [[noreturn]] void
2472 InputParameters::paramError(const std::string & param, Args... args) const
2473 {
2474  std::ostringstream oss;
2475  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2476  const auto [prefix, node] = paramMessageContext(param);
2477  callMooseError(prefix + oss.str(), false, node, /* show_trace = */ false);
2478 }
2479 
2480 namespace Moose
2481 {
2482 namespace internal
2483 {
2484 template <typename T>
2485 constexpr T *
2487 {
2488  return nullptr;
2489 }
2490 
2491 #ifdef MOOSE_MFEM_ENABLED
2492 
2493 template <typename T>
2494 constexpr bool
2496 {
2497  return std::is_same_v<T, MFEMScalarCoefficientName> ||
2498  std::is_same_v<T, MFEMVectorCoefficientName>;
2499 }
2500 
2501 template <typename T, typename A>
2502 constexpr bool
2503 isMFEMFunctorNameTypeHelper(std::vector<T, A> *)
2504 {
2505  return isMFEMFunctorNameTypeHelper(getNullptrExample<T>());
2506 }
2507 
2508 #endif
2509 
2510 template <typename T>
2511 constexpr bool
2513 {
2514  return std::is_same_v<T, MooseFunctorName>
2515 #ifdef MOOSE_MFEM_ENABLED
2516  || std::is_same_v<T, MFEMScalarCoefficientName>
2517 #endif
2518  ;
2519 }
2520 
2521 template <typename T, typename A>
2522 constexpr bool
2523 isScalarFunctorNameTypeHelper(std::vector<T, A> *)
2524 {
2525  return isScalarFunctorNameTypeHelper(getNullptrExample<T>());
2526 }
2527 
2528 template <typename T>
2529 constexpr bool
2531 {
2532 #ifdef MOOSE_MFEM_ENABLED
2533  return std::is_same_v<T, MFEMVectorCoefficientName>;
2534 #else
2535  return false;
2536 #endif
2537 }
2538 
2539 template <typename T, typename A>
2540 constexpr bool
2541 isVectorFunctorNameTypeHelper(std::vector<T, A> *)
2542 {
2543  return isVectorFunctorNameTypeHelper(getNullptrExample<T>());
2544 }
2545 
2546 template <typename T>
2547 constexpr bool
2549 {
2551 }
2552 }
2553 }
2554 
2555 template <typename T>
2556 constexpr bool
2558 {
2559  return Moose::internal::isFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>());
2560 }
2561 
2562 template <typename T>
2563 std::string
2564 InputParameters::appendFunctorDescription(const std::string & doc_string) const
2565 {
2566  auto numeric_value_type = []()
2567  {
2569  Moose::internal::getNullptrExample<T>()))
2570  return "number";
2572  Moose::internal::getNullptrExample<T>()))
2573  return "numeric vector value (enclosed in curly braces)";
2574  else
2575  {
2576  mooseAssert(false, "We control instantiations of this method");
2577  return "";
2578  }
2579  };
2580 
2581  return MooseUtils::trim(doc_string, ". ") + ". A functor is any of the following: a variable, " +
2582  (
2583 #ifdef MOOSE_MFEM_ENABLED
2584  Moose::internal::isMFEMFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>())
2585  ? "an MFEM"
2586  :
2587 #endif
2588  "a functor") +
2589  " material property, a function, a postprocessor or a " + numeric_value_type() + ".";
2590 }
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.
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 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
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.
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.