21#include "libmesh/utility.h"
22#include "libmesh/simple_range.h"
39 _collapse_nesting(false),
40 _moose_object_syntax_visibility(true),
41 _show_deprecated_message(true),
49 : Parameters(), _show_deprecated_message(true), _allow_copy(true)
55 : _show_deprecated_message(true), _allow_copy(true)
58 Parameters::operator=(rhs);
93 auto & metadata =
_params[name];
100 metadata._set_by_add_param =
false;
103 if (!have_parameter<MooseEnum>(name) && !have_parameter<MultiMooseEnum>(name))
104 metadata._valid =
true;
108std::optional<std::string>
114 auto deprecation_message = [
this](
const auto & name,
const auto & message) -> std::string
117 if (
_params.count(name) && !libmesh_map_find(
_params, name)._deprecation_message.empty())
118 return deprecation_message(name,
119 "The parameter '" + name +
"' is deprecated.\n" +
120 libmesh_map_find(
_params, name)._deprecation_message);
123 return deprecation_message(name_in, it->second.second);
145 const std::string name_example =
type.size() ?
type :
"the " + name +
" object";
146 const std::string type_example =
type.size() ?
type :
"MyObject";
148 "Copying of the InputParameters object for ",
150 " is not allowed.\n\nThe likely cause for this error ",
151 "is having a constructor that does not use a const reference, all constructors\nfor "
152 "MooseObject based classes should be as follows:\n\n",
157 "(const InputParameters & parameters);");
160 Parameters::operator=(rhs);
182 Parameters::operator+=(rhs);
186 for (
auto it = rhs.
_params.begin(); it != rhs.
_params.end(); ++it)
187 _params[it->first] = it->second;
207 const std::string & doc_string)
212 auto params_it =
_params.find(coupled_vars_it->second);
213 if (params_it ==
_params.end())
214 mooseError(
"There must have been a mistake in the construction of the new to deprecated "
215 "coupled vars map because the old name ",
216 coupled_vars_it->second,
217 " doesn't exist in the parameters data.");
219 params_it->second._doc_string = doc_string;
226 addParam<std::vector<VariableName>>(name, doc_string);
228 auto & metadata =
_params[name];
229 metadata._coupled_default.assign(1, value);
230 metadata._have_coupled_default =
true;
238 const std::vector<Real> & value,
239 const std::string & doc_string)
242 addParam<std::vector<VariableName>>(name, doc_string);
244 auto & metadata =
_params[name];
245 metadata._coupled_default = value;
246 metadata._have_coupled_default =
true;
255 addParam<std::vector<VariableName>>(name, doc_string);
264 const std::string & new_name,
265 const std::string & removal_date )
272 auto params_it =
_params.find(new_name);
273 std::string doc_string;
274 if (params_it !=
_params.end())
275 doc_string = params_it->second._doc_string;
277 addParam<std::vector<VariableName>>(old_name, doc_string);
281 std::string deprecation_message =
282 "The coupled variable parameter '" + old_name +
"' has been deprecated";
283 if (!removal_date.empty())
284 deprecation_message +=
" and will be removed " + removal_date;
285 deprecation_message +=
". Please use the '" + new_name +
"' coupled variable parameter instead.";
286 _params[old_name]._deprecation_message = deprecation_message;
292 const std::string & base_name,
293 const std::string & num_name,
294 const std::string & doc_string)
296 addParam<std::vector<VariableName>>(name, doc_string);
298 _params[name]._autobuild_vecs = std::make_pair(base_name, num_name);
301 addParam<std::string>(base_name, doc_string +
" (base_name)");
302 addParam<unsigned int>(num_name, doc_string +
" (num_name)");
307 const std::string & base_name,
308 const std::string & num_name,
309 const std::string & doc_string)
311 addRequiredParam<std::vector<VariableName>>(name, doc_string);
319 addRequiredParam<std::vector<VariableName>>(name, doc_string);
328 std::string doc_string;
331 for (
const auto & ch : it->second._doc_string)
334 doc_string +=
" ... ";
349 mooseError(
"Unable to set the documentation string (using setDocString) for the \"",
351 "\" parameter, the parameter does not exist.");
352 it->second._doc_string = doc;
359 return _params.at(name)._doc_unit;
366 _params[name]._doc_unit = doc_unit;
382 _params[name]._required =
false;
389 if (have_parameter<MooseEnum>(name))
390 return get<MooseEnum>(name).isValid();
393 for (
auto it =
get<std::vector<MooseEnum>>(name).
begin();
394 it != get<std::vector<MooseEnum>>(name).
end();
400 else if (have_parameter<MultiMooseEnum>(name))
401 return get<MultiMooseEnum>(name).isValid();
404 for (
auto it =
get<std::vector<MultiMooseEnum>>(name).begin();
405 it != get<std::vector<MultiMooseEnum>>(name).
end();
411 else if (have_parameter<ExecFlagEnum>(name))
412 return get<ExecFlagEnum>(name).isValid();
421 return _params.count(name) > 0 &&
_params.at(name)._set_by_add_param;
428 return _params.count(name) > 0 && !
_params.at(name)._deprecation_message.empty();
431#ifdef MOOSE_KOKKOS_ENABLED
442 for (
const auto & it : *
this)
457 std::set<ExecFlagType> execute_flags)
459 std::vector<std::string> names;
460 MooseUtils::tokenize<std::string>(input_names, names, 1,
" ");
461 for (
auto & name_in : names)
464 auto map_iter =
_params.find(name);
467 map_iter->second._controllable =
true;
468 map_iter->second._controllable_flags = execute_flags;
473 "' does not exist, thus cannot be marked as controllable.");
484const std::set<ExecFlagType> &
508 mooseError(
"InputParameters::getBase(): Parameters do not have base; one needs to be set with "
516 InputParameters::set<std::string>(
"_moose_warehouse_system_name") = value;
517 _params[
"_moose_warehouse_system_name"]._is_private =
true;
523 mooseAssert(have_parameter<std::string>(
"_moose_warehouse_system_name"),
524 "SystemAttributeName is not available! Call 'registerSystemAttributeName' (usually "
525 "in the validParams function) before you try accessing it!");
526 return Parameters::get<std::string>(
"_moose_warehouse_system_name");
538 const std::string & name,
545const std::vector<std::string> &
551const std::vector<std::tuple<std::string,
583#define checkMooseType(param_type, name) \
584 if (have_parameter<param_type>(name) || have_parameter<std::vector<param_type>>(name)) \
585 error = "non-controllable type '" + type(name) + "' for parameter '" + \
586 paramFullpath(param_name) + "' marked controllable";
594 std::vector<std::string> required_param_errors;
595 for (
const auto & it : *
this)
605 required_param_errors.push_back(
"missing required parameter '" + parampath +
"/" +
606 param_name +
"'\n\tDoc String: \"" +
611 if (required_param_errors.size())
615 for (
const auto & [name, param_ptr] : *
this)
617 if (
const auto error =
parameterRangeCheck(*param_ptr, parampath +
"/" + name, name,
false))
622 mooseError(
"For range checked parameter '" + name +
"': " + error->second);
631 "private parameter '" +
paramFullpath(param_name) +
"' marked controllable");
633 std::optional<std::string> error;
634 checkMooseType(NonlinearVariableName, param_name);
635 checkMooseType(AuxVariableName, param_name);
636 checkMooseType(VariableName, param_name);
637 checkMooseType(BoundaryName, param_name);
638 checkMooseType(SubdomainName, param_name);
639 checkMooseType(PostprocessorName, param_name);
640 checkMooseType(VectorPostprocessorName, param_name);
641 checkMooseType(UserObjectName, param_name);
642 checkMooseType(MaterialPropertyName, param_name);
648std::optional<std::pair<bool, std::string>>
650 const std::string & long_name,
651 const std::string & short_name,
652 const bool include_param_path)
654#define dynamicCastRangeCheck(type, up_type, long_name, short_name) \
657 if (const auto scalar_p = dynamic_cast<const InputParameters::Parameter<type> *>(&value)) \
658 return rangeCheck<type, up_type>(long_name, short_name, *scalar_p, include_param_path); \
659 if (const auto vector_p = \
660 dynamic_cast<const InputParameters::Parameter<std::vector<type>> *>(&value)) \
661 return rangeCheck<type, up_type>(long_name, short_name, *vector_p, include_param_path); \
664 dynamicCastRangeCheck(Real, Real, long_name, short_name);
665 dynamicCastRangeCheck(
int,
long, long_name, short_name);
666 dynamicCastRangeCheck(
long,
long, long_name, short_name);
667 dynamicCastRangeCheck(
unsigned int,
long, long_name, short_name);
668#undef dynamicCastRangeCheck
681 for (
const auto & name_value : *
this)
683 const auto & param_name = name_value.first;
684 const auto & param_value = name_value.second;
687 const auto set_filename = [&](
auto & value)
689 constexpr bool is_data_file_name =
690 std::is_same_v<std::decay_t<
decltype(value)>, DataFileName>;
695 if constexpr (!is_data_file_name)
715 if constexpr (!is_data_file_name)
727 catch (std::exception & e)
736#define set_if_filename(type) \
737 else if (auto type_value = dynamic_cast<Parameters::Parameter<type> *>(param_value.get())) \
738 set_filename(type_value->set()); \
739 else if (auto type_values = dynamic_cast<Parameters::Parameter<std::vector<type>> *>( \
740 param_value.get())) for (auto & value : type_values->set()) set_filename(value)
744 set_if_filename(FileName);
745 set_if_filename(FileNameNoExtension);
746 set_if_filename(MeshFileName);
747 set_if_filename(MatrixFileName);
748 set_if_filename(DataFileName);
749#undef set_if_filename
758 mooseAssert(!have_parameter<std::string>(
"_app_name"),
759 "Not currently setup to work with app FileName parameters");
761 const hit::Node * hit_node =
nullptr;
771 return std::filesystem::current_path();
774 while (hit_node && hit_node->filename() ==
"CLI_ARGS")
775 hit_node = hit_node->parent();
780 const std::string error =
"Input context was set via a command-line argument and does not have "
781 "sufficient context for determining a file path.";
788 return std::filesystem::absolute(std::filesystem::path(hit_node->filename()).parent_path());
795 return !
_params.find(name)->second._range_function.empty();
802 return _params.at(name)._range_function;
815 mooseError(
"No way to know if the parameter '", param_name,
"' has a default");
829 setCoupledVar(coupling_name, std::vector<VariableName>{value});
834 const std::vector<VariableName> &
values)
839 mooseError(
"Unable to set coupled variable parameter '",
841 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
843 set<std::vector<VariableName>>(actual_name) =
values;
846const std::vector<VariableName> &
852 mooseError(
"Unable to get coupled variable parameter '",
854 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
856 return get<std::vector<VariableName>>(actual_name);
862 return _params.count(coupling_name) > 0 &&
_params.at(coupling_name)._have_coupled_default &&
870 _params[actual_name]._coupled_default.resize(i + 1);
871 _params[actual_name]._coupled_default[i] = value;
872 _params[actual_name]._have_coupled_default =
true;
878 auto value_it =
_params.find(coupling_name);
880 if (value_it ==
_params.end() || !value_it->second._have_coupled_default)
881 mooseError(
"Attempted to retrieve default value for coupled variable '",
883 "' when none was provided. \n\nThere are three reasons why this may have "
884 "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
885 "to provide a default value. \n 2. This should have been a required coupled "
886 "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
887 "coupled value should have been properly guarded with isCoupled()\n");
889 return value_it->second._coupled_default.at(i);
895 auto value_it =
_params.find(coupling_name);
897 mooseError(
"Attempted to retrieve default value for coupled variable '",
899 "' when none was provided.");
900 return value_it->second._coupled_default.size();
903std::map<std::string, std::pair<std::string, std::string>>
906 std::map<std::string, std::pair<std::string, std::string>> abv;
909 if (!it->second._autobuild_vecs.first.empty())
910 abv[it->first] = it->second._autobuild_vecs;
920 mooseError(
"Parameter \"", name,
"\" not found.\n\n", *
this);
923 return "std::vector<VariableName>";
924 else if (
_params.count(name) > 0 && !
_params.at(name)._custom_type.empty())
925 return _params.at(name)._custom_type;
926 return _values.at(name)->type();
935 if (have_parameter<VariableName>(name))
936 var = get<VariableName>(name);
937 else if (have_parameter<NonlinearVariableName>(name))
938 var = get<NonlinearVariableName>(name);
939 else if (have_parameter<LinearVariableName>(name))
940 var = get<LinearVariableName>(name);
941 else if (have_parameter<AuxVariableName>(name))
942 var = get<AuxVariableName>(name);
943 else if (have_parameter<PostprocessorName>(name))
944 var = get<PostprocessorName>(name);
945 else if (have_parameter<VectorPostprocessorName>(name))
946 var = get<VectorPostprocessorName>(name);
947 else if (have_parameter<FunctionName>(name))
948 var = get<FunctionName>(name);
949 else if (have_parameter<UserObjectName>(name))
950 var = get<UserObjectName>(name);
951 else if (have_parameter<MaterialPropertyName>(name))
952 var = get<MaterialPropertyName>(name);
953 else if (have_parameter<std::string>(name))
954 var = get<std::string>(name);
959std::vector<std::string>
963 std::vector<std::string> svars;
967 std::vector<VariableName>
vars = get<std::vector<VariableName>>(name);
968 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
970 else if (
have_parameter<std::vector<NonlinearVariableName>>(name))
972 std::vector<NonlinearVariableName>
vars = get<std::vector<NonlinearVariableName>>(name);
973 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
977 std::vector<AuxVariableName>
vars = get<std::vector<AuxVariableName>>(name);
978 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
982 std::vector<MaterialPropertyName>
vars = get<std::vector<MaterialPropertyName>>(name);
983 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
987 std::vector<std::string>
vars = get<std::vector<std::string>>(name);
988 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
1028 const std::string group_name)
1030 std::vector<std::string> elements;
1035 std::set<std::string> param_names;
1036 for (
const auto & it : *
this)
1037 param_names.insert(it.first);
1039 for (
const auto & param_name : elements)
1040 if (
_params.count(param_name) > 0)
1042 std::string & group =
_params[param_name]._group;
1043 if (!group.empty() && group == group_name)
1045 "The parameter '", param_name,
"' has already been added to the group '", group,
"'.");
1049 mooseError(
"Unable to find a parameter with name: ",
1051 " when adding to group ",
1061 "Unable to find a parameter with name: ", name,
" when moving to group ", group_name,
'.');
1062 _params[name]._group = group_name;
1069 if (param.second._group == old_name)
1070 param.second._group = new_name;
1078 mooseError(
"InputParameters::setGlobalCommandLineParam: The parameter '",
1080 "' is not a command line parameter");
1081 cl_data->global =
true;
1090std::optional<InputParameters::CommandLineMetadata>
1104 mooseError(
"InputParameters::getCommandLineMetadata: The parameter '",
1106 "' is not a command line parameter");
1115 mooseError(
"InputParameters::commandLineParamSet: The parameter '",
1117 "' is not a command line parameter");
1118 cl_data->set_by_command_line =
true;
1125 auto it =
_params.find(param_name);
1127 return it->second._group;
1128 return std::string();
1133 const std::vector<std::string> & exclude,
1134 const bool allow_private)
1141 for (
const auto & it : common)
1144 const std::string & common_name = it.first;
1146 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1156 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1165 const std::vector<std::string> & exclude,
1166 const bool allow_private)
1168 for (
const auto & it : common)
1170 const std::string & common_name = it.first;
1171 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1180 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1190 const std::vector<std::string> & include,
1194 for (
const auto & it : common)
1197 const std::string & common_name = it.first;
1200 if (std::find(include.begin(), include.end(), common_name) == include.end())
1212 const std::string var_name = *it;
1215 if (std::find(include.begin(), include.end(), var_name) == include.end())
1251 const std::string & common_name,
1261 const bool local_exist =
_values.find(local_name) !=
_values.end();
1262 const bool local_set =
_params.count(local_name) > 0 && !
_params[local_name]._set_by_add_param;
1263 const bool local_priv = allow_private ? false :
isPrivate(local_name);
1267 const bool common_exist = common.
_values.find(common_name) != common.
_values.end();
1268 const bool common_priv = allow_private ? false : common.
isPrivate(common_name);
1269 const bool common_valid = common.
isParamValid(common_name);
1277 if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
1278 (!common_priv || !local_priv))
1281 _values[local_name] = common.
_values.find(common_name)->second->clone();
1283 _params[local_name]._set_by_add_param =
1284 libmesh_map_find(common.
_params, common_name)._set_by_add_param;
1290 else if (!local_exist && !common_exist)
1291 mooseError(
"InputParameters::applyParameter(): Attempted to apply invalid parameter \"",
1303 mooseDeprecated(
"paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
1319 return cl_data->set_by_command_line;
1321 return !
_params.at(name)._set_by_add_param && !
_params.at(name)._is_private;
1328 return _params.count(name) > 0;
1337 mooseError(
"No parameter exists with the name ", name);
1338 return it->second._doc_string;
1343InputParameters::addRequiredParam<MooseEnum>(
const std::string & name,
1345 const std::string & doc_string)
1347 InputParameters::set<MooseEnum>(name) = moose_enum;
1348 auto & metadata =
_params[name];
1349 metadata._required =
true;
1350 metadata._doc_string = doc_string;
1355InputParameters::addRequiredParam<MultiMooseEnum>(
const std::string & name,
1357 const std::string & doc_string)
1359 InputParameters::set<MultiMooseEnum>(name) =
1361 auto & metadata =
_params[name];
1362 metadata._required =
true;
1363 metadata._doc_string = doc_string;
1368InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1369 const std::string & name,
1370 const std::vector<MooseEnum> & moose_enums,
1371 const std::string & doc_string)
1373 InputParameters::set<std::vector<MooseEnum>>(name) =
1375 auto & metadata = _params[name];
1376 metadata._required =
true;
1377 metadata._doc_string = doc_string;
1382InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
1383 const std::string & name,
1384 const std::vector<MultiMooseEnum> & moose_enums,
1385 const std::string & doc_string)
1388 moose_enums.size() == 1,
1389 "Only 1 MultiMooseEnum is supported in addRequiredParam<std::vector<MultiMooseEnum>> for " +
1391 mooseAssert(!moose_enums[0].items().empty(),
1392 "The MultiMooseEnum in addRequiredParam<std::vector<MultiMooseEnum>> is empty for " +
1394 InputParameters::set<std::vector<MultiMooseEnum>>(name) =
1396 auto & metadata = _params[name];
1397 metadata._required =
true;
1398 metadata._doc_string = doc_string;
1403InputParameters::addParam<MooseEnum>(
const std::string & ,
1404 const std::string & )
1406 mooseError(
"You must supply a MooseEnum object when using addParam, even if the parameter is not "
1412InputParameters::addParam<MultiMooseEnum>(
const std::string & ,
1413 const std::string & )
1415 mooseError(
"You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1416 "is not required!");
1421InputParameters::addParam<std::vector<MooseEnum>>(
const std::string & ,
1422 const std::string & )
1424 mooseError(
"You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1425 "parameter is not required!");
1430InputParameters::addParam<std::vector<MultiMooseEnum>>(
const std::string & ,
1431 const std::string & )
1434 "You must supply a vector of MultiMooseEnum object(s) when using addParam, even if the "
1435 "parameter is not required!");
1440InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
const std::string & ,
1441 const std::string & )
1443 mooseError(
"You must supply a vector of MultiMooseEnum object(s) when using addRequiredParam!");
1448InputParameters::addPrivateParam<MooseEnum>(
const std::string & )
1450 mooseError(
"You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1451 "is not required!");
1456InputParameters::addPrivateParam<MultiMooseEnum>(
const std::string & )
1458 mooseError(
"You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1459 "parameter is not required!");
1464InputParameters::addDeprecatedParam<MooseEnum>(
const std::string & ,
1465 const std::string & ,
1466 const std::string & )
1468 mooseError(
"You must supply a MooseEnum object and the deprecation string when using "
1469 "addDeprecatedParam, even if the parameter is not required!");
1474InputParameters::addDeprecatedParam<MultiMooseEnum>(
const std::string & ,
1475 const std::string & ,
1476 const std::string & )
1478 mooseError(
"You must supply a MultiMooseEnum object and the deprecation string when using "
1479 "addDeprecatedParam, even if the parameter is not required!");
1484InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1485 const std::string & ,
1486 const std::string & ,
1487 const std::string & )
1489 mooseError(
"You must supply a vector of MooseEnum object(s) and the deprecation string when "
1490 "using addDeprecatedParam, even if the parameter is not required!");
1495InputParameters::setParamHelper<PostprocessorName, Real>(
const std::string & ,
1496 PostprocessorName & l_value,
1497 const Real & r_value)
1500 std::ostringstream oss;
1502 l_value = oss.str();
1507InputParameters::setParamHelper<PostprocessorName, int>(
const std::string & ,
1508 PostprocessorName & l_value,
1509 const int & r_value)
1512 std::ostringstream oss;
1514 l_value = oss.str();
1519InputParameters::setParamHelper<FunctionName, Real>(
const std::string & ,
1520 FunctionName & l_value,
1521 const Real & r_value)
1524 std::ostringstream oss;
1526 l_value = oss.str();
1531InputParameters::setParamHelper<FunctionName, int>(
const std::string & ,
1532 FunctionName & l_value,
1533 const int & r_value)
1536 std::ostringstream oss;
1538 l_value = oss.str();
1543InputParameters::setParamHelper<MaterialPropertyName, Real>(
const std::string & ,
1544 MaterialPropertyName & l_value,
1545 const Real & r_value)
1548 std::ostringstream oss;
1550 l_value = oss.str();
1555InputParameters::setParamHelper<MaterialPropertyName, int>(
const std::string & ,
1556 MaterialPropertyName & l_value,
1557 const int & r_value)
1560 std::ostringstream oss;
1562 l_value = oss.str();
1567InputParameters::setParamHelper<MooseFunctorName, Real>(
const std::string & ,
1568 MooseFunctorName & l_value,
1569 const Real & r_value)
1572 std::ostringstream oss;
1574 l_value = oss.str();
1579InputParameters::setParamHelper<MooseFunctorName, int>(
const std::string & ,
1580 MooseFunctorName & l_value,
1581 const int & r_value)
1584 std::ostringstream oss;
1586 l_value = oss.str();
1591InputParameters::getParamHelper<MooseEnum>(
const std::string & name_in,
1600InputParameters::getParamHelper<MultiMooseEnum>(
const std::string & name_in,
1609 const std::set<std::string> & reserved)
1612 _params[name]._reserved_values = reserved;
1615std::set<std::string>
1621 return std::set<std::string>();
1622 return it->second._reserved_values;
1629 return hit_node->fileLocation(
false);
1637 return hit_node->fullpath();
1649 const hit::Node & node,
1652 mooseAssert(node.type() == hit::NodeType::Field,
"Must be a field");
1660 return hit_node->fileLocation(
false);
1668 return hit_node->fullpath();
1675 const static pcrecpp::RE valid(
"[\\w:/]+");
1676 if (!valid.FullMatch(name))
1677 mooseError(
"Invalid parameter name: '", name,
"'");
1686 return it->second._ignore;
1687 mooseError(
"Parameter ", name,
" does not exist");
1690std::set<std::string>
1693 std::set<std::string> names;
1695 if (it->second._group == group)
1696 names.emplace(it->first);
1700std::set<std::string>
1703 std::set<std::string> param_set;
1705 param_set.emplace(it->first);
1709std::set<std::string>
1712 std::set<std::string> controllable;
1714 if (it->second._controllable)
1715 controllable.emplace(it->first);
1716 return controllable;
1722 auto prefix = param +
":";
1732 return hit_node->strVal();
1738 const std::string & moose_object_with_var_param_name)
const
1741 std::string variable_name =
getMooseType(var_param_name);
1742 if (variable_name ==
"")
1752 moose_object_with_var_param_name,
1753 "' while retrieving value for '",
1755 "' parameter! Did you forget to set '",
1757 "' or set it to '' (empty string) by accident?");
1761 variable_name = vec[0];
1764 return variable_name;
1769 const std::string & new_name,
1770 const std::string & docstring,
1771 const std::string & removal_date)
1773 auto params_it =
_params.find(old_name);
1774 if (params_it ==
_params.end())
1775 mooseError(
"Requested to rename parameter '",
1777 "' but that parameter name doesn't exist in the parameters object.");
1778 mooseAssert(params_it->second._deprecation_message.empty(),
1779 "Attempting to rename the parameter, '" << old_name <<
"', that is deprecated");
1781 auto new_metadata = std::move(params_it->second);
1782 if (!docstring.empty())
1783 new_metadata._doc_string = docstring;
1784 _params.emplace(new_name, std::move(new_metadata));
1787 auto values_it =
_values.find(old_name);
1788 auto new_value = std::move(values_it->second);
1789 _values.emplace(new_name, std::move(new_value));
1792 std::string deprecation_message;
1793 if (!removal_date.empty())
1794 deprecation_message =
"'" + old_name +
"' has been deprecated and will be removed on " +
1795 removal_date +
". Please use '" + new_name +
"' instead.";
1803 const std::string & new_name,
1804 const std::string & docstring,
1805 const std::string & removal_date)
1809 mooseError(
"Requested to rename coupled variable '",
1811 "' but that coupled variable name doesn't exist in the parameters object.");
1821 const std::string & new_name,
1822 const std::string & new_docstring)
1829 const std::string & new_name,
1830 const std::string & new_docstring)
1837 const std::string & new_name,
1838 const std::string & removal_date)
1845 const std::string & new_name,
1846 const std::string & removal_date)
1855 return it->second.first;
1860std::vector<std::string>
1864 "The parameter we are searching for aliases for should exist in our parameter map");
1865 std::vector<std::string> aliases = {param_name};
1868 aliases.push_back(pr.second);
1873std::optional<Moose::DataFileUtils::Path>
1879std::optional<std::string>
1881 const hit::Node & node,
1885 bool has_name =
false;
1887 bool has_default =
false;
1893 for (
const auto i : index_range(names))
1895 auto & name = names[i];
1897 if (MooseUtils::convert<Real>(name, real_value,
false))
1909 return {
"invalid value for '" + node.fullpath() +
1910 "': coupled vectors where some parameters are reals and others are variables are not "
1920std::pair<std::string, const hit::Node *>
1923 const hit::Node * node =
nullptr;
1925 std::string fullpath;
1927 if (
const hit::Node * param_node =
getHitNode(param))
1929 fullpath = param_node->fullpath();
1933 else if (
const hit::Node * block_node =
getHitNode())
1936 fullpath = block_node->fullpath() +
"/" + param;
1942 return {fullpath +
": ", node};
1956 const bool with_prefix ,
1957 const hit::Node * node ,
1958 const bool show_trace )
const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
std::array< Real, 2 > values
Base class for MOOSE-based applications.
static const std::string kokkos_object_param
The name of the parameter that indicates an object is a Kokkos functor.
static const std::string moose_base_param
The name of the parameter that contains the moose system base.
static const std::string name_param
The name of the parameter that contains the object name.
static const std::string type_param
The name of the parameter that contains the object type.
void callMooseError(std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
External method for calling moose error with added object context.
static const std::string app_param
The name of the parameter that contains the MooseApp.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Scoped helper for setting Moose::_throw_on_error during this scope.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
void remove(std::string_view)
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 ...
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
Path getPath(std::string path, const GetPathOptions &options={})
Get the data path for a given path, searching the registered data.
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
The type for the callback to set RelationshipManager parameters.
RelationshipManagerType
Main types of Relationship Managers.
std::string hitMessagePrefix(const hit::Node &node)
Get the prefix to be associated with a hit node for a message.
Options to be passed to getPath().
bool graceful
Whether or not to error whenever a path is not found.
std::optional< std::string > base
The base path by which to search for relative paths.
bool search_all_data
Whether or not to search all registered data.
Representation of a data file path.