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 "MultiMooseEnum.h"
17 #include "ExecFlagEnum.h"
18 #include "Conversion.h"
19 #include "DataFileUtils.h"
20 #include "MoosePassKey.h"
21 
22 #include "libmesh/parameters.h"
23 
24 #ifdef LIBMESH_HAVE_FPARSER
25 #include "libmesh/fparser.hh"
26 #else
27 template <typename T>
29 {
30 }
31 #endif
32 
33 #include <tuple>
34 #include <unordered_map>
35 #include <mutex>
36 #include <optional>
37 #include <filesystem>
38 #include <regex>
39 
40 #include <gtest/gtest.h>
41 
42 // Forward declarations
43 class Action;
44 class ActionFactory;
45 class Factory;
46 class FEProblemBase;
47 class InputParameters;
48 class MooseEnum;
49 class MooseObject;
50 class MultiMooseEnum;
51 class Problem;
52 namespace hit
53 {
54 class Node;
55 }
56 namespace Moose
57 {
58 class Builder;
59 }
60 class CommandLine;
61 
67 {
68 public:
69  InputParameters(const InputParameters & rhs);
70  InputParameters(const Parameters & rhs);
71 
72  virtual ~InputParameters() = default;
73 
74  virtual void clear() override;
75 
80  {
82  {
86  };
87 
89  std::string syntax;
91  std::vector<std::string> switches;
95  bool required;
97  bool set_by_command_line = false;
99  bool global = false;
100  };
101 
107  {
108  friend class Action;
109  friend class ActionFactory;
110  friend class Moose::Builder;
111  friend class Factory;
112  friend class FEProblemBase;
113  friend class InputParameters;
114  FRIEND_TEST(InputParametersTest, fileNames);
117  };
118 
124  {
125  friend class Moose::Builder;
126  FRIEND_TEST(InputParametersTest, fileNames);
129  };
130 
138  template <typename T>
140  {
141  static constexpr bool value =
142  std::is_same_v<T, std::string> || std::is_same_v<T, std::vector<std::string>> ||
143  std::is_same_v<T, Real> || std::is_same_v<T, unsigned int> || std::is_same_v<T, int> ||
144  std::is_same_v<T, bool> || std::is_same_v<T, MooseEnum>;
145  };
146 
151  void addClassDescription(const std::string & doc_string);
152 
156  std::string getClassDescription() const;
157 
161  virtual void set_attributes(const std::string & name, bool inserted_only) override;
162 
166  std::optional<std::string> queryDeprecatedParamMessage(const std::string & name) const;
167 
169  template <typename T>
170  void setHelper(const std::string & name);
171 
187  template <typename T>
188  T & set(const std::string & name, bool quiet_mode = false);
189 
201  template <typename T, typename... Ts>
202  void setParameters(const std::string & name, const T & value, Ts... extra_input_parameters);
203 
211  template <typename T, typename UP_T>
213  std::optional<std::pair<bool, std::string>>
214  rangeCheck(const std::string & full_name,
215  const std::string & short_name,
216  const InputParameters::Parameter<T> & param,
217  const bool include_param_path = true);
218  template <typename T, typename UP_T>
219  std::optional<std::pair<bool, std::string>>
220  rangeCheck(const std::string & full_name,
221  const std::string & short_name,
222  const InputParameters::Parameter<std::vector<T>> & param,
223  const bool include_param_path = true);
225 
229  template <typename T>
230  T getCheckedPointerParam(const std::string & name, const std::string & error_string = "") const;
231 
237  template <typename T>
238  void addRequiredParam(const std::string & name, const std::string & doc_string);
239 
244  template <typename T>
245  void
246  addRequiredParam(const std::string & name, const T & moose_enum, const std::string & doc_string);
247 
249 
255  template <typename T, typename S>
256  void addParam(const std::string & name, const S & value, const std::string & doc_string);
257  template <typename T>
258  void addParam(const std::string & name, const std::string & doc_string);
260 
264  template <typename T>
265  void addParam(const std::string & name,
266  const std::initializer_list<typename T::value_type> & value,
267  const std::string & doc_string)
268  {
269  addParam<T>(name, T{value}, doc_string);
270  }
271 
273  // BEGIN RANGE CHECKED PARAMETER METHODS
278  template <typename T>
279  void addRequiredRangeCheckedParam(const std::string & name,
280  const std::string & parsed_function,
281  const std::string & doc_string);
282  template <typename T>
283  void addRangeCheckedParam(const std::string & name,
284  const T & value,
285  const std::string & parsed_function,
286  const std::string & doc_string);
287  template <typename T>
288  void addRangeCheckedParam(const std::string & name,
289  const std::string & parsed_function,
290  const std::string & doc_string);
291  // END RANGE CHECKED PARAMETER METHODS
293 
298  template <typename T>
299  void addRequiredCustomTypeParam(const std::string & name,
300  const std::string & custom_type,
301  const std::string & doc_string);
302  template <typename T>
303  void addCustomTypeParam(const std::string & name,
304  const T & value,
305  const std::string & custom_type,
306  const std::string & doc_string);
307  template <typename T>
308  void addCustomTypeParam(const std::string & name,
309  const std::string & custom_type,
310  const std::string & doc_string);
311  template <typename T>
312  void addDeprecatedCustomTypeParam(const std::string & name,
313  const std::string & custom_type,
314  const std::string & doc_string,
315  const std::string & deprecation_msg);
316 
323  template <typename T>
324  void addPrivateParam(const std::string & name, const T & value);
325  template <typename T>
326  void addPrivateParam(const std::string & name);
327 
337  template <typename T>
338  void addRequiredCommandLineParam(const std::string & name,
339  const std::string & syntax,
340  const std::string & doc_string);
341  template <typename T>
342  void addCommandLineParam(const std::string & name,
343  const std::string & syntax,
344  const std::string & doc_string);
345  template <typename T>
346  void addCommandLineParam(const std::string & name,
347  const std::string & syntax,
348  const T & value,
349  const std::string & doc_string);
350  template <typename T>
351  void addCommandLineParam(const std::string & name,
352  const std::string & syntax,
353  const std::initializer_list<typename T::value_type> & value,
354  const std::string & doc_string)
355  {
356  addCommandLineParam<T>(name, syntax, T{value}, doc_string);
357  }
358 
376  template <typename T>
377  void addOptionalValuedCommandLineParam(const std::string & name,
378  const std::string & syntax,
379  const T & value,
380  const std::string & doc_string);
381 
387  void setGlobalCommandLineParam(const std::string & name);
388 
396  template <typename T>
397  void addDeprecatedParam(const std::string & name,
398  const T & value,
399  const std::string & doc_string,
400  const std::string & deprecation_message);
401 
402  template <typename T>
403  void addDeprecatedParam(const std::string & name,
404  const std::string & doc_string,
405  const std::string & deprecation_message);
406 
416  template <typename T>
417  void checkConsistentType(const std::string & name) const;
418 
422  bool isCommandLineParameter(const std::string & name) const;
423 
429  std::optional<InputParameters::CommandLineMetadata>
430  queryCommandLineMetadata(const std::string & name) const;
431 
436  getCommandLineMetadata(const std::string & name) const;
437 
443  {
444  friend class CommandLine;
445  FRIEND_TEST(InputParametersTest, commandLineParamSetNotCLParam);
448  };
454  void commandLineParamSet(const std::string & name, const CommandLineParamSetKey);
455 
459  const std::string & getDescription(const std::string & name) const;
460 
466  void addParamNamesToGroup(const std::string & space_delim_names, const std::string group_name);
467 
473  void renameParameterGroup(const std::string & old_name, const std::string & new_name);
474 
479  std::string getGroupName(const std::string & param_name) const;
480 
487  template <typename T>
488  void suppressParameter(const std::string & name);
489 
494  template <typename T>
495  void makeParamRequired(const std::string & name);
496 
501  template <typename T>
502  void makeParamNotRequired(const std::string & name);
503 
509  void addCoupledVar(const std::string & name, const std::string & doc_string);
510 
518  void addDeprecatedCoupledVar(const std::string & old_name,
519  const std::string & new_name,
520  const std::string & removal_date = "");
521 
530  void addCoupledVar(const std::string & name, const Real value, const std::string & doc_string);
531 
540  void addCoupledVar(const std::string & name,
541  const std::vector<Real> & value,
542  const std::string & doc_string);
543 
545 
562  void addCoupledVarWithAutoBuild(const std::string & name,
563  const std::string & base_name,
564  const std::string & num_name,
565  const std::string & doc_string);
566  void addRequiredCoupledVarWithAutoBuild(const std::string & name,
567  const std::string & base_name,
568  const std::string & num_name,
569  const std::string & doc_string);
571 
577  std::string getMooseType(const std::string & name) const;
578  std::vector<std::string> getVecMooseType(const std::string & name) const;
579 
587  bool isMooseBaseObject() const;
588 
592  const std::string * queryObjectType() const;
593 
599  const std::string & getObjectType() const;
603  const std::string & getObjectName() const;
604 
614  void addRequiredCoupledVar(const std::string & name, const std::string & doc_string);
615 
619  std::string getDocString(const std::string & name) const;
620 
628  void setDocString(const std::string & name, const std::string & doc);
629 
633  std::string getDocUnit(const std::string & name) const;
634 
641  void setDocUnit(const std::string & name, const std::string & doc_unit);
642 
646  bool isParamRequired(const std::string & name) const;
647 
651  void makeParamNotRequired(const std::string & name);
652 
658  bool isParamValid(const std::string & name) const;
659 
665  bool isParamSetByAddParam(const std::string & name) const;
666 
670  bool isParamDeprecated(const std::string & name) const;
671 
676  bool areAllRequiredParamsValid() const;
677 
681  std::string type(const std::string & name) const;
682 
686  bool isPrivate(const std::string & name) const;
687 
691  void declareControllable(const std::string & name, std::set<ExecFlagType> execute_flags = {});
692 
696  void markControlled(const std::string & name);
697 
701  bool isControllable(const std::string & name) const;
702 
706  const std::set<ExecFlagType> & getControllableExecuteOnTypes(const std::string & name) const;
707 
713  void registerBase(const std::string & value);
714 
720  bool hasBase() const;
721 
727  const std::string & getBase() const;
728 
740  void registerSystemAttributeName(const std::string & value);
741 
746  const std::string & getSystemAttributeName() const;
747 
755  void registerBuildableTypes(const std::string & names);
756 
772  const std::string & name,
774  Moose::RelationshipManagerInputParameterCallback input_parameter_callback = nullptr);
775 
780 
784  const std::vector<std::string> & getBuildableTypes() const;
785 
789  const std::vector<std::tuple<std::string,
793 
795 
799  void collapseSyntaxNesting(bool collapse);
800  bool collapseSyntaxNesting() const;
802 
804 
808  void mooseObjectSyntaxVisibility(bool visibility);
809  bool mooseObjectSyntaxVisibility() const;
811 
813 
816  using Parameters::operator=;
817  using Parameters::operator+=;
821 
828  void checkParams(const std::string & parsing_syntax);
829 
839  std::optional<std::pair<bool, std::string>> parameterRangeCheck(const Parameters::Value & value,
840  const std::string & long_name,
841  const std::string & short_name,
842  const bool include_param_path);
843 
851  void finalize(const std::string & parsing_syntax);
852 
866  std::filesystem::path
867  getFileBase(const std::optional<std::string> & param_name = std::optional<std::string>()) const;
868 
873  inline std::set<std::string>::const_iterator coupledVarsBegin() const
874  {
875  return _coupled_vars.begin();
876  }
877  inline std::set<std::string>::const_iterator coupledVarsEnd() const
878  {
879  return _coupled_vars.end();
880  }
881 
885  const std::set<std::string> & getCoupledVariableParamNames() const { return _coupled_vars; }
886 
890  const std::unordered_map<std::string, std::string> & getNewToDeprecatedVarMap() const
891  {
893  }
894 
896  bool isRangeChecked(const std::string & param_name) const;
897 
899  std::string rangeCheckedFunction(const std::string & name) const;
900 
902  bool hasDefault(const std::string & param_name) const;
903 
909  bool hasCoupledValue(const std::string & coupling_name) const;
910 
916  bool hasDefaultCoupledValue(const std::string & coupling_name) const;
917 
924  Real defaultCoupledValue(const std::string & coupling_name, unsigned int i = 0) const;
925 
931  unsigned int numberDefaultCoupledValues(const std::string & coupling_name) const;
932 
940  void defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i = 0);
941 
945  std::map<std::string, std::pair<std::string, std::string>> getAutoBuildVectors() const;
946 
947  // BEGIN APPLY PARAMETER METHODS
965  void applyParameters(const InputParameters & common,
966  const std::vector<std::string> & exclude = {},
967  const bool allow_private = false);
968 
986  void applySpecificParameters(const InputParameters & common,
987  const std::vector<std::string> & include,
988  bool allow_private = false);
989 
1002  void applyParameter(const InputParameters & common,
1003  const std::string & common_name,
1004  bool allow_private = false,
1005  bool override_default = false);
1006  // END APPLY PARAMETER METHODS
1007 
1018  void applyCoupledVar(const InputParameters & common, const std::string & var_name);
1019 
1023  bool paramSetByUser(const std::string & name) const;
1024 
1029  bool isParamSetByUser(const std::string & name) const;
1030 
1036  bool isParamDefined(const std::string & name) const;
1037 
1039  /*
1040  * These methods are here to retrieve parameters for scalar and vector types respectively. We will
1041  * throw errors
1042  * when returning most scalar and vector types.
1043  */
1044  template <typename T>
1045  static const T & getParamHelper(const std::string & name, const InputParameters & pars);
1047 
1048  using Parameters::get;
1049 
1051  template <typename R1,
1052  typename R2,
1053  typename V1 = typename std::conditional<std::is_same<R1, MooseEnumItem>::value,
1055  std::vector<R1>>::type,
1056  typename V2 = typename std::conditional<std::is_same<R2, MooseEnumItem>::value,
1058  std::vector<R2>>::type>
1059  std::vector<std::pair<R1, R2>> get(const std::string & param1, const std::string & param2) const;
1060 
1064  std::set<std::string> getParametersList() const;
1065 
1069  std::set<std::string> getControllableParameters() const;
1070 
1074  std::set<std::string> getGroupParameters(const std::string & group) const;
1075 
1080  void setReservedValues(const std::string & name, const std::set<std::string> & reserved);
1081 
1086  std::set<std::string> reservedValues(const std::string & name) const;
1087 
1092  std::string blockLocation() const;
1093 
1098  std::string blockFullpath() const;
1099 
1103  const hit::Node * getHitNode(const std::string & param) const;
1109  void setHitNode(const std::string & param, const hit::Node & node, const SetParamHitNodeKey);
1110 
1115  std::string inputLocation(const std::string & param) const;
1116 
1121  std::string paramFullpath(const std::string & param) const;
1122 
1126  std::string paramLocationPrefix(const std::string & param) const;
1127 
1135  template <typename... Args>
1136  std::string paramMessage(const std::string & param, Args... args) const;
1137 
1141  template <typename... Args>
1142  [[noreturn]] void mooseError(Args &&... args) const;
1143 
1148  template <typename... Args>
1149  [[noreturn]] void paramError(const std::string & param, Args... args) const;
1150 
1155  std::string rawParamVal(const std::string & param) const;
1156 
1161  template <typename T>
1162  void ignoreParameter(const std::string & name);
1163 
1168  bool shouldIgnore(const std::string & name);
1169 
1173  template <typename T>
1174  bool isType(const std::string & name) const;
1175 
1182  std::string varName(const std::string & var_param_name,
1183  const std::string & moose_object_with_var_param_name) const;
1184 
1192  void renameParam(const std::string & old_name,
1193  const std::string & new_name,
1194  const std::string & new_docstring);
1195 
1202  void renameCoupledVar(const std::string & old_name,
1203  const std::string & new_name,
1204  const std::string & new_docstring);
1205 
1206  void deprecateParam(const std::string & old_name,
1207  const std::string & new_name,
1208  const std::string & removal_date);
1209 
1210  void deprecateCoupledVar(const std::string & old_name,
1211  const std::string & new_name,
1212  const std::string & removal_date);
1213 
1220  std::string checkForRename(const std::string & name) const;
1221 
1228  template <typename T>
1229  const T & get(std::string_view name) const;
1230 
1239  template <typename T>
1240  bool have_parameter(std::string_view name) const;
1241 
1249  template <typename T>
1250  void transferParam(const InputParameters & source_param,
1251  const std::string & name,
1252  const std::string & new_name = "",
1253  const std::string & new_description = "");
1254 
1267  std::vector<std::string> paramAliases(const std::string & param_name) const;
1268 
1273  const hit::Node * getHitNode() const { return _hit_node; }
1281  void setHitNode(const hit::Node & node, const SetHitNodeKey) { _hit_node = &node; }
1282 
1286  bool isFinalized() const { return _finalized; }
1287 
1291  std::optional<Moose::DataFileUtils::Path> queryDataFileNamePath(const std::string & name) const;
1292 
1301  std::optional<std::string> setupVariableNames(std::vector<VariableName> & names,
1302  const hit::Node & node,
1304 
1305 private:
1306  // Private constructor so that InputParameters can only be created in certain places.
1307  InputParameters();
1308 
1312  void setParameters() {}
1313 
1314  template <typename T>
1315  static constexpr bool isFunctorNameType();
1316 
1320  template <typename T>
1321  std::string appendFunctorDescription(const std::string & doc_string) const;
1322 
1326  void setDeprecatedVarDocString(const std::string & new_name, const std::string & doc_string);
1327 
1328  void renameParamInternal(const std::string & old_name,
1329  const std::string & new_name,
1330  const std::string & docstring,
1331  const std::string & removal_date);
1332 
1333  void renameCoupledVarInternal(const std::string & old_name,
1334  const std::string & new_name,
1335  const std::string & docstring,
1336  const std::string & removal_date);
1337 
1344  std::pair<std::string, const hit::Node *> paramMessageContext(const std::string & param) const;
1350  std::string paramMessagePrefix(const std::string & param) const;
1351 
1352  struct Metadata
1353  {
1354  std::string _doc_string;
1356  std::string _doc_unit;
1358  std::string _custom_type;
1360  std::optional<CommandLineMetadata> _cl_data;
1362  std::optional<Moose::DataFileUtils::Path> _data_file_name_path;
1364  std::string _group;
1366  std::string _range_function;
1368  std::pair<std::string, std::string> _autobuild_vecs;
1370  bool _required = false;
1376  bool _valid = false;
1378  bool _is_private = false;
1381  std::vector<Real> _coupled_default = {0};
1383  bool _set_by_add_param = false;
1385  std::set<std::string> _reserved_values;
1389  const hit::Node * _hit_node;
1391  bool _controllable = false;
1393  std::set<ExecFlagType> _controllable_flags;
1395  bool _ignore = false;
1396  };
1397 
1398  Metadata & at(const std::string & param_name)
1399  {
1400  const auto param = checkForRename(param_name);
1401  if (_params.count(param) == 0)
1402  mooseError("param '", param, "' not present in InputParams");
1403  return _params[param];
1404  }
1405  const Metadata & at(const std::string & param_name) const
1406  {
1407  const auto param = checkForRename(param_name);
1408  if (_params.count(param) == 0)
1409  mooseError("param '", param, "' not present in InputParams");
1410  return _params.at(param);
1411  }
1412 
1423 
1427  void checkParamName(const std::string & name) const;
1428 
1433  template <typename T, typename S>
1434  void setParamHelper(const std::string & name, T & l_value, const S & r_value);
1435 
1444  template <typename T>
1445  void addCommandLineParamHelper(const std::string & name,
1446  const std::string & syntax,
1447  const bool required,
1448  const bool value_required);
1449 
1454  [[noreturn]] void callMooseError(std::string msg,
1455  const bool with_prefix = true,
1456  const hit::Node * node = nullptr) const;
1457 
1460  std::map<std::string, Metadata> _params;
1461 
1463  std::set<std::string> _coupled_vars;
1464 
1467  std::string _class_description;
1468 
1471  std::vector<std::string> _buildable_types;
1472 
1477  std::vector<std::tuple<std::string,
1481 
1485 
1488 
1492 
1495 
1497  std::unordered_map<std::string, std::string> _new_to_deprecated_coupled_vars;
1498 
1503  std::map<std::string, std::pair<std::string, std::string>> _old_to_new_name_and_dep;
1504 
1507  std::multimap<std::string, std::string> _new_to_old_names;
1508 
1510  const hit::Node * _hit_node;
1511 
1514 
1515  // These are the only objects allowed to _create_ InputParameters
1518  friend class Parser;
1519  // for the printInputFile function in the action warehouse
1520  friend class ActionWarehouse;
1521 };
1522 
1523 template <typename T>
1524 void
1525 InputParameters::setHelper(const std::string & /*name*/)
1526 {
1527 }
1528 
1529 // Template and inline function implementations
1530 template <typename T>
1531 T &
1532 InputParameters::set(const std::string & name_in, bool quiet_mode)
1533 {
1534  const auto name = checkForRename(name_in);
1535 
1537  checkConsistentType<T>(name);
1538 
1539  T & result = this->Parameters::set<T>(name);
1540 
1541  if (quiet_mode)
1542  _params[name]._set_by_add_param = true;
1543 
1544  setHelper<T>(name);
1545 
1546  return result;
1547 }
1548 
1549 template <typename T, typename... Ts>
1550 void
1551 InputParameters::setParameters(const std::string & name,
1552  const T & value,
1553  Ts... extra_input_parameters)
1554 {
1555  this->set<T>(name) = value;
1556  this->setParameters(extra_input_parameters...);
1557 }
1558 
1559 template <typename T, typename UP_T>
1560 std::optional<std::pair<bool, std::string>>
1561 InputParameters::rangeCheck(const std::string & full_name,
1562  const std::string & short_name,
1563  const InputParameters::Parameter<std::vector<T>> & param,
1564  const bool include_param_path)
1565 {
1566  if (!isParamValid(short_name))
1567  return {};
1568 
1569  const auto & range_function = _params[short_name]._range_function;
1570  if (range_function.empty())
1571  return {};
1572 
1585  std::vector<std::string> vars;
1586  if (fp.ParseAndDeduceVariables(range_function, vars) != -1) // -1 for success
1587  return {{false,
1588  "Error parsing expression '" + range_function + "' for parameter " + short_name + ""}};
1589 
1590  // Fparser parameter buffer
1591  std::vector<UP_T> parbuf(vars.size());
1592 
1593  // parameter vector
1594  const std::vector<T> & value = param.get();
1595 
1596  // iterate over all vector values (maybe ;)
1597  bool need_to_iterate = false;
1598  unsigned int i = 0;
1599  do
1600  {
1601  // set parameters
1602  for (unsigned int j = 0; j < vars.size(); j++)
1603  {
1604  if (vars[j] == short_name)
1605  {
1606  if (value.size() == 0)
1607  {
1608  std::ostringstream oss;
1609  oss << "Range checking empty vector";
1610  if (include_param_path)
1611  oss << " parameter " << full_name;
1612  oss << "; expression = '" << range_function << "'";
1613  return {{true, oss.str()}};
1614  }
1615 
1616  parbuf[j] = value[i];
1617  need_to_iterate = true;
1618  }
1619  else if (vars[j] == short_name + "_size")
1620  parbuf[j] = value.size();
1621  else
1622  {
1623  if (vars[j].substr(0, short_name.size() + 1) != short_name + "_")
1624  return {{false, "Error parsing expression '" + range_function + "'"}};
1625  std::istringstream iss(vars[j]);
1626  iss.seekg(short_name.size() + 1);
1627 
1628  size_t index;
1629  if (iss >> index && iss.eof())
1630  {
1631  if (index >= value.size())
1632  {
1633  std::ostringstream oss;
1634  oss << "Error parsing expression '" + range_function + "'";
1635  if (include_param_path)
1636  oss << " for parameter " << full_name;
1637  oss << "; out of range variable '" + vars[j] << "'";
1638  return {{true, oss.str()}};
1639  }
1640  parbuf[j] = value[index];
1641  }
1642  else
1643  return {{false,
1644  "Error parsing expression '" + range_function + "'; invalid variable '" +
1645  vars[j] + "'"}};
1646  }
1647  }
1648 
1649  // ensure range-checked input file parameter comparison functions
1650  // do absolute floating point comparisons instead of using a default epsilon.
1651  auto tmp_eps = fp.epsilon();
1652  fp.setEpsilon(0);
1653  UP_T result = fp.Eval(&parbuf[0]);
1654  fp.setEpsilon(tmp_eps);
1655 
1656  // test function using the parameters determined above
1657  if (fp.EvalError())
1658  return {{false, "Error evaluating expression '" + range_function + "'"}};
1659 
1660  if (!result)
1661  {
1662  std::ostringstream oss;
1663  oss << "Range check failed";
1664  if (include_param_path)
1665  oss << " for parameter " << full_name;
1666  oss << "; expression = '" << range_function << "'";
1667  if (need_to_iterate)
1668  oss << ", component " << i;
1669  return {{true, oss.str()}};
1670  }
1671 
1672  } while (need_to_iterate && ++i < value.size());
1673 
1674  return {};
1675 }
1676 
1677 template <typename T, typename UP_T>
1678 std::optional<std::pair<bool, std::string>>
1679 InputParameters::rangeCheck(const std::string & full_name,
1680  const std::string & short_name,
1681  const InputParameters::Parameter<T> & param,
1682  const bool include_param_path)
1683 {
1684  if (!isParamValid(short_name))
1685  return {};
1686 
1687  const auto & range_function = _params[short_name]._range_function;
1688  if (range_function.empty())
1689  return {};
1690 
1691  // Parse the expression
1693  if (fp.Parse(range_function, short_name) != -1) // -1 for success
1694  return {{false,
1695  "Error parsing expression '" + range_function + "'" + " for parameter " + short_name}};
1696 
1697  // ensure range-checked input file parameter comparison functions
1698  // do absolute floating point comparisons instead of using a default epsilon.
1699  auto tmp_eps = fp.epsilon();
1700  fp.setEpsilon(0);
1701  // We require a non-const value for the implicit upscaling of the parameter type
1702  std::vector<UP_T> value(1, param.get());
1703  UP_T result = fp.Eval(&value[0]);
1704  fp.setEpsilon(tmp_eps);
1705 
1706  if (fp.EvalError())
1707  return {{true,
1708  "Error evaluating expression '" + range_function + "' for parameter " + short_name +
1709  "; perhaps you used the wrong variable name?"}};
1710 
1711  if (!result)
1712  {
1713  std::ostringstream oss;
1714  oss << "Range check failed";
1715  if (include_param_path)
1716  oss << " for parameter " << full_name;
1717  oss << "; expression = '" << range_function << "', value = " << value[0];
1718  return {{true, oss.str()}};
1719  }
1720 
1721  return {};
1722 }
1723 
1724 template <typename T>
1725 T
1726 InputParameters::getCheckedPointerParam(const std::string & name_in,
1727  const std::string & error_string) const
1728 {
1729  const auto name = checkForRename(name_in);
1730 
1731  T param = this->get<T>(name);
1732 
1733  // Note: You will receive a compile error on this line if you attempt to pass a non-pointer
1734  // template type to this method
1735  if (!param)
1736  mooseError("Parameter ", name, " is NULL.\n", error_string);
1737  return this->get<T>(name);
1738 }
1739 
1740 template <typename T>
1741 void
1742 InputParameters::addRequiredParam(const std::string & name, const std::string & doc_string)
1743 {
1745  checkConsistentType<T>(name);
1746 
1747  InputParameters::insert<T>(name);
1748  auto & metadata = _params[name];
1749  metadata._required = true;
1750  if constexpr (isFunctorNameType<T>())
1751  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1752  else
1753  metadata._doc_string = doc_string;
1754 }
1755 
1756 template <typename T>
1757 void
1758 InputParameters::addRequiredParam(const std::string & /*name*/,
1759  const T & /*value*/,
1760  const std::string & /*doc_string*/)
1761 {
1762  mooseError("You cannot call addRequiredParam and supply a default value for this type, please "
1763  "use addParam instead");
1764 }
1765 
1766 template <typename T, typename S>
1767 void
1768 InputParameters::addParam(const std::string & name, const S & value, const std::string & doc_string)
1769 {
1771  checkConsistentType<T>(name);
1772 
1773  T & l_value = InputParameters::set<T>(name);
1774  auto & metadata = _params[name];
1775  if constexpr (isFunctorNameType<T>())
1776  metadata._doc_string = appendFunctorDescription<T>(doc_string);
1777  else
1778  metadata._doc_string = doc_string;
1779 
1780  // Set the parameter now
1781  setParamHelper(name, l_value, value);
1782 
1783  /* Indicate the default value, as set via addParam, is being used. The parameter is removed from
1784  the list whenever
1785  it changes, see set_attributes */
1786  metadata._set_by_add_param = true;
1787 }
1788 
1789 template <typename T>
1790 void
1791 InputParameters::addParam(const std::string & name, const std::string & doc_string)
1792 {
1794  checkConsistentType<T>(name);
1795 
1796  InputParameters::insert<T>(name);
1797  if constexpr (isFunctorNameType<T>())
1798  _params[name]._doc_string = appendFunctorDescription<T>(doc_string);
1799  else
1800  _params[name]._doc_string = doc_string;
1801 }
1802 
1803 template <typename T, typename S>
1804 void
1805 InputParameters::setParamHelper(const std::string & /*name*/, T & l_value, const S & r_value)
1806 {
1807  l_value = r_value;
1808 }
1809 
1810 template <typename T>
1811 void
1813  const std::string & syntax,
1814  const bool required,
1815  const bool value_required)
1816 {
1817  static_assert(isValidCommandLineType<T>::value,
1818  "This type is not a supported command line parameter type. See "
1819  "CommandLine::populateCommandLineParams to add it as a supported type.");
1820 
1821  auto & cl_data = at(name)._cl_data;
1822  cl_data = CommandLineMetadata();
1823 
1824  // Split up the syntax by whitespace
1825  std::vector<std::string> syntax_split;
1826  MooseUtils::tokenize(syntax, syntax_split, 1, " \t\n\v\f\r");
1827 
1828  // Set the single syntax string as the combined syntax with removed whitespace
1829  cl_data->syntax = MooseUtils::stringJoin(syntax_split);
1830  mooseAssert(cl_data->syntax.size(), "Empty token");
1831 
1832  // Set the switches; only parse those that begin with "-" as we also
1833  // provide examples within the syntax
1834  for (const auto & val : syntax_split)
1835  if (val.rfind("-", 0) == 0)
1836  {
1837  if (!std::regex_search(val, std::regex("^\\-+[a-zA-Z]")))
1838  mooseError("The switch '",
1839  val,
1840  "' for the command line parameter '",
1841  name,
1842  "' is invalid. It must begin with an alphabetical character.");
1843 
1844  cl_data->switches.push_back(val);
1846  }
1847 
1848  cl_data->required = required;
1849  cl_data->global = false;
1850 
1851  // No arguments needed for a boolean parameter
1852  if constexpr (std::is_same_v<T, bool>)
1853  {
1854  (void)value_required; // purposely unused; doesn't take a value
1855  cl_data->argument_type = CommandLineMetadata::ArgumentType::NONE;
1856  }
1857  // MooseEnums require a value
1858  else if constexpr (std::is_same_v<T, MooseEnum>)
1859  {
1860  (void)value_required; // purposely unused; always required
1861  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1862  }
1863  // The user didn't specify a default, so a value is required
1864  else if (value_required)
1865  cl_data->argument_type = CommandLineMetadata::ArgumentType::REQUIRED;
1866  // Otherwise, it's optional (user specified a default)
1867  else
1868  cl_data->argument_type = CommandLineMetadata::ArgumentType::OPTIONAL;
1869 }
1870 
1871 template <typename T>
1872 void
1874  const std::string & parsed_function,
1875  const std::string & doc_string)
1876 {
1877  addRequiredParam<T>(name, doc_string);
1878  _params[name]._range_function = parsed_function;
1879 }
1880 
1881 template <typename T>
1882 void
1883 InputParameters::addRangeCheckedParam(const std::string & name,
1884  const T & value,
1885  const std::string & parsed_function,
1886  const std::string & doc_string)
1887 {
1888  addParam<T>(name, value, doc_string);
1889  _params[name]._range_function = parsed_function;
1890 }
1891 
1892 template <typename T>
1893 void
1894 InputParameters::addRangeCheckedParam(const std::string & name,
1895  const std::string & parsed_function,
1896  const std::string & doc_string)
1897 {
1898  addParam<T>(name, doc_string);
1899  _params[name]._range_function = parsed_function;
1900 }
1901 
1902 template <typename T>
1903 void
1905  const std::string & custom_type,
1906  const std::string & doc_string)
1907 {
1908  addRequiredParam<T>(name, doc_string);
1909  _params[name]._custom_type = custom_type;
1910 }
1911 
1912 template <typename T>
1913 void
1914 InputParameters::addCustomTypeParam(const std::string & name,
1915  const T & value,
1916  const std::string & custom_type,
1917  const std::string & doc_string)
1918 {
1919  addParam<T>(name, value, doc_string);
1920  _params[name]._custom_type = custom_type;
1921 }
1922 
1923 template <typename T>
1924 void
1925 InputParameters::addCustomTypeParam(const std::string & name,
1926  const std::string & custom_type,
1927  const std::string & doc_string)
1928 {
1929  addParam<T>(name, doc_string);
1930  _params[name]._custom_type = custom_type;
1931 }
1932 
1933 template <typename T>
1934 void
1936  const std::string & custom_type,
1937  const std::string & doc_string,
1938  const std::string & deprecation_message)
1939 {
1940  _show_deprecated_message = false;
1941  addParam<T>(name, doc_string);
1942  auto & metadata = _params[name];
1943  metadata._custom_type = custom_type;
1944 
1945  metadata._deprecation_message = deprecation_message;
1946  _show_deprecated_message = true;
1947 }
1948 
1949 template <typename T>
1950 void
1951 InputParameters::addPrivateParam(const std::string & name)
1952 {
1954  checkConsistentType<T>(name);
1955 
1956  InputParameters::insert<T>(name);
1957  _params[name]._is_private = true;
1958 }
1959 
1960 template <typename T>
1961 void
1962 InputParameters::addPrivateParam(const std::string & name, const T & value)
1963 {
1965  checkConsistentType<T>(name);
1966 
1967  InputParameters::set<T>(name) = value;
1968  auto & metadata = _params[name];
1969  metadata._is_private = true;
1970  metadata._set_by_add_param = true;
1971 }
1972 
1973 template <typename T>
1974 void
1976  const std::string & syntax,
1977  const std::string & doc_string)
1978 {
1979  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool");
1980 
1981  addRequiredParam<T>(name, doc_string);
1982  addCommandLineParamHelper<T>(name, syntax, /* required = */ true, /* value_required = */ true);
1983 }
1984 
1985 template <typename T>
1986 void
1987 InputParameters::addCommandLineParam(const std::string & name,
1988  const std::string & syntax,
1989  const std::string & doc_string)
1990 {
1991  static_assert(!std::is_same_v<T, MooseEnum>,
1992  "addCommandLineParam() without a value cannot be used with a MooseEnum because a "
1993  "MooseEnum requires initialization");
1994 
1995  auto constexpr is_bool = std::is_same_v<T, bool>;
1996  if constexpr (is_bool)
1997  addParam<T>(name, false, doc_string);
1998  else
1999  addParam<T>(name, doc_string);
2000 
2001  addCommandLineParamHelper<T>(
2002  name, syntax, /* required = */ false, /* value_required = */ !is_bool);
2003 }
2004 
2005 template <typename T>
2006 void
2007 InputParameters::addCommandLineParam(const std::string & name,
2008  const std::string & syntax,
2009  const T & value,
2010  const std::string & doc_string)
2011 {
2012  if constexpr (std::is_same_v<T, bool>)
2013  mooseAssert(!value, "Default for bool must be false");
2014 
2015  addParam<T>(name, value, doc_string);
2016  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ true);
2017 }
2018 
2019 template <typename T>
2020 void
2022  const std::string & syntax,
2023  const T & value,
2024  const std::string & doc_string)
2025 {
2026  mooseAssert(name == "mesh_only" || name == "recover" || name == "run",
2027  "Not supported for new parameters");
2028  static_assert(!std::is_same_v<T, bool>, "Cannot be used for a bool (does not take a value)");
2029  addParam<T>(name, value, doc_string);
2030  addCommandLineParamHelper<T>(name, syntax, /* required = */ false, /* value_required = */ false);
2031 }
2032 
2033 template <typename T>
2034 void
2035 InputParameters::checkConsistentType(const std::string & name_in) const
2036 {
2037  const auto name = checkForRename(name_in);
2038 
2039  // If we don't currently have the Parameter, can't be any inconsistency
2041  if (it == _values.end())
2042  return;
2043 
2044  // Now, if we already have the Parameter, but it doesn't have the
2045  // right type, throw an error.
2046  if (!this->Parameters::have_parameter<T>(name))
2047  mooseError("Attempting to set parameter \"",
2048  name,
2049  "\" with type (",
2050  libMesh::demangle(typeid(T).name()),
2051  ")\nbut the parameter already exists as type (",
2052  it->second->type(),
2053  ")");
2054 }
2055 
2056 template <typename T>
2057 void
2058 InputParameters::suppressParameter(const std::string & name_in)
2059 {
2060  const auto name = checkForRename(name_in);
2061  if (!this->have_parameter<T>(name))
2062  mooseError("Unable to suppress nonexistent parameter: ", name);
2063 
2064  auto & metadata = _params[name];
2065  metadata._required = false;
2066  metadata._is_private = true;
2067  metadata._controllable = false;
2068 }
2069 
2070 template <typename T>
2071 void
2072 InputParameters::ignoreParameter(const std::string & name_in)
2073 {
2074  const auto name = checkForRename(name_in);
2075  suppressParameter<T>(name);
2076  _params[name]._ignore = true;
2077 }
2078 
2079 template <typename T>
2080 void
2081 InputParameters::makeParamRequired(const std::string & name_in)
2082 {
2083  const auto name = checkForRename(name_in);
2084 
2085  if (!this->have_parameter<T>(name))
2086  mooseError("Unable to require nonexistent parameter: ", name);
2087 
2088  _params[name]._required = true;
2089 }
2090 
2091 template <typename T>
2092 void
2093 InputParameters::makeParamNotRequired(const std::string & name_in)
2094 {
2095  const auto name = checkForRename(name_in);
2096 
2097  if (!this->have_parameter<T>(name))
2098  mooseError("Unable to un-require nonexistent parameter: ", name);
2099 
2100  _params[name]._required = false;
2101 }
2102 
2103 template <typename T>
2104 void
2105 InputParameters::addDeprecatedParam(const std::string & name,
2106  const T & value,
2107  const std::string & doc_string,
2108  const std::string & deprecation_message)
2109 {
2110  _show_deprecated_message = false;
2111  mooseAssert(!_old_to_new_name_and_dep.count(name),
2112  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2113  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2114  addParam<T>(name, value, doc_string);
2115 
2116  _params[name]._deprecation_message = deprecation_message;
2117  _show_deprecated_message = true;
2118 }
2119 
2120 template <typename T>
2121 void
2122 InputParameters::addDeprecatedParam(const std::string & name,
2123  const std::string & doc_string,
2124  const std::string & deprecation_message)
2125 {
2126  _show_deprecated_message = false;
2127  mooseAssert(!_old_to_new_name_and_dep.count(name),
2128  "Attempting to deprecate via addDeprecatedParam the parameter, '"
2129  << name << "', already deprecated via deprecateParam or renamed via renameParam");
2130  addParam<T>(name, doc_string);
2131 
2132  _params[name]._deprecation_message = deprecation_message;
2133  _show_deprecated_message = true;
2134 }
2135 
2136 // Forward declare MooseEnum specializations for add*Param
2137 template <>
2138 void InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
2139  const MooseEnum & moose_enum,
2140  const std::string & doc_string);
2141 
2142 template <>
2143 void InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
2144  const MultiMooseEnum & moose_enum,
2145  const std::string & doc_string);
2146 
2147 template <>
2148 void InputParameters::addRequiredParam<std::vector<MooseEnum>>(
2149  const std::string & name,
2150  const std::vector<MooseEnum> & moose_enums,
2151  const std::string & doc_string);
2152 
2153 template <>
2154 void InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
2155  const std::string & name,
2156  const std::vector<MultiMooseEnum> & moose_enums,
2157  const std::string & doc_string);
2158 
2159 template <>
2160 void InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
2161  const std::string & /*doc_string*/);
2162 
2163 template <>
2164 void InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
2165  const std::string & /*doc_string*/);
2166 
2167 template <>
2168 void InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
2169  const std::string & /*doc_string*/);
2170 
2171 template <>
2172 void InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2173  const std::string & /*doc_string*/);
2174 
2175 template <>
2176 void
2177 InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
2178  const std::string & /*doc_string*/);
2179 
2180 template <>
2181 void InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/);
2182 
2183 template <>
2184 void InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/);
2185 
2186 template <>
2187 void InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
2188  const std::string & /*doc_string*/,
2189  const std::string & /*deprecation_message*/);
2190 
2191 template <>
2192 void
2193 InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
2194  const std::string & /*doc_string*/,
2195  const std::string & /*deprecation_message*/);
2196 
2197 template <>
2198 void InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
2199  const std::string & /*name*/,
2200  const std::string & /*doc_string*/,
2201  const std::string & /*deprecation_message*/);
2202 
2203 // Forward declare specializations for setParamHelper
2204 template <>
2205 void InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & name,
2206  PostprocessorName & l_value,
2207  const Real & r_value);
2208 
2209 template <>
2210 void InputParameters::setParamHelper<PostprocessorName, int>(const std::string & name,
2211  PostprocessorName & l_value,
2212  const int & r_value);
2213 
2214 template <>
2215 void InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
2216  FunctionName & l_value,
2217  const Real & r_value);
2218 
2219 template <>
2220 void InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
2221  FunctionName & l_value,
2222  const int & r_value);
2223 
2224 template <>
2225 void InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
2226  MaterialPropertyName & l_value,
2227  const Real & r_value);
2228 
2229 template <>
2230 void InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
2231  MaterialPropertyName & l_value,
2232  const int & r_value);
2233 
2234 template <>
2235 void InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
2236  MooseFunctorName & l_value,
2237  const Real & r_value);
2238 
2239 template <>
2240 void InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
2241  MooseFunctorName & l_value,
2242  const int & r_value);
2243 
2244 template <typename T>
2245 const T &
2246 InputParameters::getParamHelper(const std::string & name_in, const InputParameters & pars)
2247 {
2248  const auto name = pars.checkForRename(name_in);
2249 
2250  if (!pars.isParamValid(name))
2251  pars.mooseError("The parameter \"", name, "\" is being retrieved before being set.");
2252 
2253  return pars.get<T>(name);
2254 }
2255 
2256 // Declare specializations so we don't fall back on the generic
2257 // implementation, but the definition will be in InputParameters.C so
2258 // we won't need to bring in *MooseEnum header files here.
2259 template <>
2260 const MooseEnum & InputParameters::getParamHelper<MooseEnum>(const std::string & name,
2261  const InputParameters & pars);
2262 
2263 template <>
2264 const MultiMooseEnum &
2265 InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name,
2266  const InputParameters & pars);
2267 
2268 template <typename R1, typename R2, typename V1, typename V2>
2269 std::vector<std::pair<R1, R2>>
2270 InputParameters::get(const std::string & param1_in, const std::string & param2_in) const
2271 {
2272  const auto param1 = checkForRename(param1_in);
2273  const auto param2 = checkForRename(param2_in);
2274 
2275  const auto & v1 = get<V1>(param1);
2276  const auto & v2 = get<V2>(param2);
2277 
2278  auto controllable = getControllableParameters();
2279  if (controllable.count(param1) || controllable.count(param2))
2280  mooseError("Parameters ",
2281  param1,
2282  " and/or ",
2283  param2 + " are controllable parameters and cannot be retireved using "
2284  "the MooseObject::getParam/InputParameters::get methods for pairs");
2285 
2286  if (v1.size() != v2.size())
2287  paramError(param1,
2288  "Vector parameters ",
2289  param1,
2290  "(size: ",
2291  v1.size(),
2292  ") and " + param2,
2293  "(size: ",
2294  v2.size(),
2295  ") are of different lengths \n");
2296 
2297  std::vector<std::pair<R1, R2>> parameter_pairs;
2298  auto i1 = v1.begin();
2299  auto i2 = v2.begin();
2300  for (; i1 != v1.end() && i2 != v2.end(); ++i1, ++i2)
2301  parameter_pairs.emplace_back(std::make_pair(*i1, *i2));
2302  return parameter_pairs;
2303 }
2304 
2306 
2307 template <typename T>
2308 bool
2309 InputParameters::isType(const std::string & name_in) const
2310 {
2311  const auto name = checkForRename(name_in);
2312 
2313  if (!_params.count(name))
2314  mooseError("Parameter \"", name, "\" is not valid.");
2315  return have_parameter<T>(name);
2316 }
2317 
2318 template <typename T>
2319 const T &
2320 InputParameters::get(std::string_view name_in) const
2321 {
2322  const auto name = checkForRename(std::string(name_in));
2323 
2324  return Parameters::get<T>(name);
2325 }
2326 
2327 template <typename T>
2328 bool
2329 InputParameters::have_parameter(std::string_view name_in) const
2330 {
2331  const auto name = checkForRename(std::string(name_in));
2332 
2333  return Parameters::have_parameter<T>(name);
2334 }
2335 
2336 template <typename T>
2337 void
2339  const std::string & name_in,
2340  const std::string & new_name,
2341  const std::string & new_description)
2342 {
2343  const auto name = source_params.checkForRename(std::string(name_in));
2344  const auto p_name = new_name.empty() ? name_in : new_name;
2345  if (!source_params.have_parameter<T>(name) && !source_params.hasCoupledValue(name))
2346  mooseError("The '",
2347  name_in,
2348  "' parameter could not be transferred because it does not exist with type '",
2349  MooseUtils::prettyCppType<T>(),
2350  "' in the source parameters");
2351  if (name != name_in)
2352  mooseWarning("The transferred parameter " + name_in + " is deprecated in favor of " + name +
2353  " in the source parameters. The new name should likely be used for the parameter "
2354  "transfer instead.");
2355  const std::string description =
2356  new_description.empty() ? source_params.getDescription(name) : new_description;
2357 
2358  if (source_params.isParamRequired(name))
2359  {
2360  // Check for a variable parameter
2361  if (source_params.hasCoupledValue(name))
2362  addRequiredCoupledVar(p_name, description);
2363  // Enums parameters have a default list of options
2364  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2365  addRequiredParam<T>(p_name, source_params.get<T>(name), description);
2366  else if (source_params.isRangeChecked(name))
2367  addRequiredRangeCheckedParam<T>(
2368  p_name, source_params.rangeCheckedFunction(name), description);
2369  else
2370  addRequiredParam<T>(p_name, description);
2371  }
2372  else
2373  {
2374  // Check for a variable parameter
2375  if (source_params.hasCoupledValue(name))
2376  {
2377  if (!source_params.hasDefaultCoupledValue(name))
2378  addCoupledVar(p_name, description);
2379  else if (source_params.numberDefaultCoupledValues(name) == 1)
2380  addCoupledVar(p_name, source_params.defaultCoupledValue(name), description);
2381  else
2382  {
2383  std::vector<Real> coupled_values;
2384  for (const auto i : libMesh::make_range(source_params.numberDefaultCoupledValues(name)))
2385  coupled_values.push_back(source_params.defaultCoupledValue(name, i));
2386  addCoupledVar(p_name, coupled_values, description);
2387  }
2388  }
2389  else if (source_params.isRangeChecked(name))
2390  {
2391  if (source_params.hasDefault(name))
2392  addRangeCheckedParam<T>(p_name,
2393  source_params.get<T>(name),
2394  source_params.rangeCheckedFunction(name),
2395  description);
2396  else
2397  addRangeCheckedParam<T>(p_name, source_params.rangeCheckedFunction(name), description);
2398  }
2399  else if constexpr (std::is_same_v<MooseEnum, T> || std::is_same_v<MultiMooseEnum, T>)
2400  addParam<T>(p_name, source_params.get<T>(name), description);
2401  else
2402  {
2403  if (source_params.hasDefault(name))
2404  addParam<T>(p_name, source_params.get<T>(name), description);
2405  else
2406  addParam<T>(p_name, description);
2407  }
2408  }
2409 
2410  // Copy other attributes
2411  if (source_params.isPrivate(name))
2412  _params[p_name]._is_private = true;
2413  if (source_params.isControllable(name))
2414  _params[p_name]._controllable = true;
2415 }
2416 
2417 template <typename... Args>
2418 [[noreturn]] void
2419 InputParameters::mooseError(Args &&... args) const
2420 {
2421  std::ostringstream oss;
2422  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2423  callMooseError(oss.str());
2424 }
2425 
2426 template <typename... Args>
2427 std::string
2428 InputParameters::paramMessage(const std::string & param, Args... args) const
2429 {
2430  std::ostringstream oss;
2431  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2432  return paramMessagePrefix(param) + oss.str();
2433 }
2434 
2435 template <typename... Args>
2436 [[noreturn]] void
2437 InputParameters::paramError(const std::string & param, Args... args) const
2438 {
2439  std::ostringstream oss;
2440  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
2441  const auto [prefix, node] = paramMessageContext(param);
2442 
2443  Moose::show_trace = false;
2444  callMooseError(prefix + oss.str(), false, node);
2445  Moose::show_trace = true;
2446 }
2447 
2448 namespace Moose
2449 {
2450 namespace internal
2451 {
2452 template <typename T>
2453 constexpr T *
2455 {
2456  return nullptr;
2457 }
2458 
2459 #ifdef MOOSE_MFEM_ENABLED
2460 
2461 template <typename T>
2462 constexpr bool
2464 {
2465  return std::is_same_v<T, MFEMScalarCoefficientName> ||
2466  std::is_same_v<T, MFEMVectorCoefficientName>;
2467 }
2468 
2469 template <typename T, typename A>
2470 constexpr bool
2471 isMFEMFunctorNameTypeHelper(std::vector<T, A> *)
2472 {
2473  return isMFEMFunctorNameTypeHelper(getNullptrExample<T>());
2474 }
2475 
2476 #endif
2477 
2478 template <typename T>
2479 constexpr bool
2481 {
2482  return std::is_same_v<T, MooseFunctorName>
2483 #ifdef MOOSE_MFEM_ENABLED
2484  || std::is_same_v<T, MFEMScalarCoefficientName>
2485 #endif
2486  ;
2487 }
2488 
2489 template <typename T, typename A>
2490 constexpr bool
2491 isScalarFunctorNameTypeHelper(std::vector<T, A> *)
2492 {
2493  return isScalarFunctorNameTypeHelper(getNullptrExample<T>());
2494 }
2495 
2496 template <typename T>
2497 constexpr bool
2499 {
2500 #ifdef MOOSE_MFEM_ENABLED
2501  return std::is_same_v<T, MFEMVectorCoefficientName>;
2502 #else
2503  return false;
2504 #endif
2505 }
2506 
2507 template <typename T, typename A>
2508 constexpr bool
2509 isVectorFunctorNameTypeHelper(std::vector<T, A> *)
2510 {
2511  return isVectorFunctorNameTypeHelper(getNullptrExample<T>());
2512 }
2513 
2514 template <typename T>
2515 constexpr bool
2517 {
2519 }
2520 }
2521 }
2522 
2523 template <typename T>
2524 constexpr bool
2526 {
2527  return Moose::internal::isFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>());
2528 }
2529 
2530 template <typename T>
2531 std::string
2532 InputParameters::appendFunctorDescription(const std::string & doc_string) const
2533 {
2534  auto numeric_value_type = []()
2535  {
2537  Moose::internal::getNullptrExample<T>()))
2538  return "number";
2540  Moose::internal::getNullptrExample<T>()))
2541  return "numeric vector value (enclosed in curly braces)";
2542  else
2543  {
2544  mooseAssert(false, "We control instantiations of this method");
2545  return "";
2546  }
2547  };
2548 
2549  return MooseUtils::trim(doc_string, ". ") + ". A functor is any of the following: a variable, " +
2550  (
2551 #ifdef MOOSE_MFEM_ENABLED
2552  Moose::internal::isMFEMFunctorNameTypeHelper(Moose::internal::getNullptrExample<T>())
2553  ? "an MFEM"
2554  :
2555 #endif
2556  "a functor") +
2557  " material property, a function, a postprocessor or a " + numeric_value_type() + ".";
2558 }
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:123
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.
bool show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
Definition: Moose.C:818
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:964
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:357
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.
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1133
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.
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 callMooseError(std::string msg, const bool with_prefix=true, const hit::Node *node=nullptr) const
Internal helper for calling back to mooseError(), ideally from the underlying MooseBase object if it ...
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:33
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:27
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:990
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:50
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:77
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
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
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:42
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:26
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])
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.
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false, bool override_default=false)
Apply values from a single parameter in common, to a single parameter stored in this object...
std::optional< Moose::DataFileUtils::Path > queryDataFileNamePath(const std::string &name) const
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.
Definition: MooseUtils.C:951
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.
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.