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";
596 if (required_param_errors.size())
600 for (
const auto & [name, param_ptr] : *
this)
602 if (
const auto error =
parameterRangeCheck(*param_ptr, parampath +
"/" + name, name,
false))
607 mooseError(
"For range checked parameter '" + name +
"': " + error->second);
616 "private parameter '" +
paramFullpath(param_name) +
"' marked controllable");
618 std::optional<std::string> error;
619 checkMooseType(NonlinearVariableName, param_name);
620 checkMooseType(AuxVariableName, param_name);
621 checkMooseType(VariableName, param_name);
622 checkMooseType(BoundaryName, param_name);
623 checkMooseType(SubdomainName, param_name);
624 checkMooseType(PostprocessorName, param_name);
625 checkMooseType(VectorPostprocessorName, param_name);
626 checkMooseType(UserObjectName, param_name);
627 checkMooseType(MaterialPropertyName, param_name);
633std::vector<std::string>
635 const std::set<std::string> & skip_required_params,
636 bool skip_private)
const
641 std::vector<std::string> required_param_errors;
642 for (
const auto & it : *
this)
645 if (skip_required_params.count(param_name) || (skip_private &&
isPrivate(param_name)))
655 required_param_errors.push_back(
"missing required parameter '" + parampath +
"/" +
656 param_name +
"'\n\tDoc String: \"" +
661 return required_param_errors;
664std::optional<std::pair<bool, std::string>>
666 const std::string & long_name,
667 const std::string & short_name,
668 const bool include_param_path)
670#define dynamicCastRangeCheck(type, up_type, long_name, short_name) \
673 if (const auto scalar_p = dynamic_cast<const InputParameters::Parameter<type> *>(&value)) \
674 return rangeCheck<type, up_type>(long_name, short_name, *scalar_p, include_param_path); \
675 if (const auto vector_p = \
676 dynamic_cast<const InputParameters::Parameter<std::vector<type>> *>(&value)) \
677 return rangeCheck<type, up_type>(long_name, short_name, *vector_p, include_param_path); \
680 dynamicCastRangeCheck(Real, Real, long_name, short_name);
681 dynamicCastRangeCheck(
int,
long, long_name, short_name);
682 dynamicCastRangeCheck(
long,
long, long_name, short_name);
683 dynamicCastRangeCheck(
unsigned int,
long, long_name, short_name);
684#undef dynamicCastRangeCheck
697 for (
const auto & name_value : *
this)
699 const auto & param_name = name_value.first;
700 const auto & param_value = name_value.second;
703 const auto set_filename = [&](
auto & value)
705 constexpr bool is_data_file_name =
706 std::is_same_v<std::decay_t<
decltype(value)>, DataFileName>;
711 if constexpr (!is_data_file_name)
731 if constexpr (!is_data_file_name)
743 catch (std::exception & e)
752#define set_if_filename(type) \
753 else if (auto type_value = dynamic_cast<Parameters::Parameter<type> *>(param_value.get())) \
754 set_filename(type_value->set()); \
755 else if (auto type_values = dynamic_cast<Parameters::Parameter<std::vector<type>> *>( \
756 param_value.get())) for (auto & value : type_values->set()) set_filename(value)
760 set_if_filename(FileName);
761 set_if_filename(FileNameNoExtension);
762 set_if_filename(MeshFileName);
763 set_if_filename(MatrixFileName);
764 set_if_filename(DataFileName);
765#undef set_if_filename
774 mooseAssert(!have_parameter<std::string>(
"_app_name"),
775 "Not currently setup to work with app FileName parameters");
777 const hit::Node * hit_node =
nullptr;
787 return std::filesystem::current_path();
790 while (hit_node && hit_node->filename() ==
"CLI_ARGS")
791 hit_node = hit_node->parent();
796 const std::string error =
"Input context was set via a command-line argument and does not have "
797 "sufficient context for determining a file path.";
804 return std::filesystem::absolute(std::filesystem::path(hit_node->filename()).parent_path());
811 return !
_params.find(name)->second._range_function.empty();
818 return _params.at(name)._range_function;
831 mooseError(
"No way to know if the parameter '", param_name,
"' has a default");
845 setCoupledVar(coupling_name, std::vector<VariableName>{value});
850 const std::vector<VariableName> &
values)
855 mooseError(
"Unable to set coupled variable parameter '",
857 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
859 set<std::vector<VariableName>>(actual_name) =
values;
862const std::vector<VariableName> &
868 mooseError(
"Unable to get coupled variable parameter '",
870 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
872 return get<std::vector<VariableName>>(actual_name);
878 return _params.count(coupling_name) > 0 &&
_params.at(coupling_name)._have_coupled_default &&
886 _params[actual_name]._coupled_default.resize(i + 1);
887 _params[actual_name]._coupled_default[i] = value;
888 _params[actual_name]._have_coupled_default =
true;
894 auto value_it =
_params.find(coupling_name);
896 if (value_it ==
_params.end() || !value_it->second._have_coupled_default)
897 mooseError(
"Attempted to retrieve default value for coupled variable '",
899 "' when none was provided. \n\nThere are three reasons why this may have "
900 "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
901 "to provide a default value. \n 2. This should have been a required coupled "
902 "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
903 "coupled value should have been properly guarded with isCoupled()\n");
905 return value_it->second._coupled_default.at(i);
911 auto value_it =
_params.find(coupling_name);
913 mooseError(
"Attempted to retrieve default value for coupled variable '",
915 "' when none was provided.");
916 return value_it->second._coupled_default.size();
919std::map<std::string, std::pair<std::string, std::string>>
922 std::map<std::string, std::pair<std::string, std::string>> abv;
925 if (!it->second._autobuild_vecs.first.empty())
926 abv[it->first] = it->second._autobuild_vecs;
936 mooseError(
"Parameter \"", name,
"\" not found.\n\n", *
this);
939 return "std::vector<VariableName>";
940 else if (
_params.count(name) > 0 && !
_params.at(name)._custom_type.empty())
941 return _params.at(name)._custom_type;
942 return _values.at(name)->type();
951 if (have_parameter<VariableName>(name))
952 var = get<VariableName>(name);
953 else if (have_parameter<NonlinearVariableName>(name))
954 var = get<NonlinearVariableName>(name);
955 else if (have_parameter<LinearVariableName>(name))
956 var = get<LinearVariableName>(name);
957 else if (have_parameter<AuxVariableName>(name))
958 var = get<AuxVariableName>(name);
959 else if (have_parameter<PostprocessorName>(name))
960 var = get<PostprocessorName>(name);
961 else if (have_parameter<VectorPostprocessorName>(name))
962 var = get<VectorPostprocessorName>(name);
963 else if (have_parameter<FunctionName>(name))
964 var = get<FunctionName>(name);
965 else if (have_parameter<UserObjectName>(name))
966 var = get<UserObjectName>(name);
967 else if (have_parameter<MaterialPropertyName>(name))
968 var = get<MaterialPropertyName>(name);
969 else if (have_parameter<std::string>(name))
970 var = get<std::string>(name);
975std::vector<std::string>
979 std::vector<std::string> svars;
983 std::vector<VariableName>
vars = get<std::vector<VariableName>>(name);
984 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
986 else if (
have_parameter<std::vector<NonlinearVariableName>>(name))
988 std::vector<NonlinearVariableName>
vars = get<std::vector<NonlinearVariableName>>(name);
989 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
993 std::vector<AuxVariableName>
vars = get<std::vector<AuxVariableName>>(name);
994 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
998 std::vector<MaterialPropertyName>
vars = get<std::vector<MaterialPropertyName>>(name);
999 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
1003 std::vector<std::string>
vars = get<std::vector<std::string>>(name);
1004 std::copy(
vars.begin(),
vars.end(), std::back_inserter(svars));
1044 const std::string group_name)
1046 std::vector<std::string> elements;
1051 std::set<std::string> param_names;
1052 for (
const auto & it : *
this)
1053 param_names.insert(it.first);
1055 for (
const auto & param_name : elements)
1056 if (
_params.count(param_name) > 0)
1058 std::string & group =
_params[param_name]._group;
1059 if (!group.empty() && group == group_name)
1061 "The parameter '", param_name,
"' has already been added to the group '", group,
"'.");
1065 mooseError(
"Unable to find a parameter with name: ",
1067 " when adding to group ",
1077 "Unable to find a parameter with name: ", name,
" when moving to group ", group_name,
'.');
1078 _params[name]._group = group_name;
1085 if (param.second._group == old_name)
1086 param.second._group = new_name;
1094 mooseError(
"InputParameters::setGlobalCommandLineParam: The parameter '",
1096 "' is not a command line parameter");
1097 cl_data->global =
true;
1106std::optional<InputParameters::CommandLineMetadata>
1120 mooseError(
"InputParameters::getCommandLineMetadata: The parameter '",
1122 "' is not a command line parameter");
1131 mooseError(
"InputParameters::commandLineParamSet: The parameter '",
1133 "' is not a command line parameter");
1134 cl_data->set_by_command_line =
true;
1141 auto it =
_params.find(param_name);
1143 return it->second._group;
1144 return std::string();
1149 const std::vector<std::string> & exclude,
1150 const bool allow_private)
1157 for (
const auto & it : common)
1160 const std::string & common_name = it.first;
1162 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1172 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1181 const std::vector<std::string> & exclude,
1182 const bool allow_private)
1184 for (
const auto & it : common)
1186 const std::string & common_name = it.first;
1187 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1196 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1206 const std::vector<std::string> & include,
1210 for (
const auto & it : common)
1213 const std::string & common_name = it.first;
1216 if (std::find(include.begin(), include.end(), common_name) == include.end())
1228 const std::string var_name = *it;
1231 if (std::find(include.begin(), include.end(), var_name) == include.end())
1267 const std::string & common_name,
1277 const bool local_exist =
_values.find(local_name) !=
_values.end();
1278 const bool local_set =
_params.count(local_name) > 0 && !
_params[local_name]._set_by_add_param;
1279 const bool local_priv = allow_private ? false :
isPrivate(local_name);
1283 const bool common_exist = common.
_values.find(common_name) != common.
_values.end();
1284 const bool common_priv = allow_private ? false : common.
isPrivate(common_name);
1285 const bool common_valid = common.
isParamValid(common_name);
1293 if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
1294 (!common_priv || !local_priv))
1297 _values[local_name] = common.
_values.find(common_name)->second->clone();
1299 _params[local_name]._set_by_add_param =
1300 libmesh_map_find(common.
_params, common_name)._set_by_add_param;
1306 else if (!local_exist && !common_exist)
1307 mooseError(
"InputParameters::applyParameter(): Attempted to apply invalid parameter \"",
1319 mooseDeprecated(
"paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
1335 return cl_data->set_by_command_line;
1337 return !
_params.at(name)._set_by_add_param && !
_params.at(name)._is_private;
1344 return _params.count(name) > 0;
1353 mooseError(
"No parameter exists with the name ", name);
1354 return it->second._doc_string;
1359InputParameters::addRequiredParam<MooseEnum>(
const std::string & name,
1361 const std::string & doc_string)
1363 InputParameters::set<MooseEnum>(name) = moose_enum;
1364 auto & metadata =
_params[name];
1365 metadata._required =
true;
1366 metadata._doc_string = doc_string;
1371InputParameters::addRequiredParam<MultiMooseEnum>(
const std::string & name,
1373 const std::string & doc_string)
1375 InputParameters::set<MultiMooseEnum>(name) =
1377 auto & metadata =
_params[name];
1378 metadata._required =
true;
1379 metadata._doc_string = doc_string;
1384InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1385 const std::string & name,
1386 const std::vector<MooseEnum> & moose_enums,
1387 const std::string & doc_string)
1389 InputParameters::set<std::vector<MooseEnum>>(name) =
1391 auto & metadata = _params[name];
1392 metadata._required =
true;
1393 metadata._doc_string = doc_string;
1398InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
1399 const std::string & name,
1400 const std::vector<MultiMooseEnum> & moose_enums,
1401 const std::string & doc_string)
1404 moose_enums.size() == 1,
1405 "Only 1 MultiMooseEnum is supported in addRequiredParam<std::vector<MultiMooseEnum>> for " +
1407 mooseAssert(!moose_enums[0].items().empty(),
1408 "The MultiMooseEnum in addRequiredParam<std::vector<MultiMooseEnum>> is empty for " +
1410 InputParameters::set<std::vector<MultiMooseEnum>>(name) =
1412 auto & metadata = _params[name];
1413 metadata._required =
true;
1414 metadata._doc_string = doc_string;
1419InputParameters::addParam<MooseEnum>(
const std::string & ,
1420 const std::string & )
1422 mooseError(
"You must supply a MooseEnum object when using addParam, even if the parameter is not "
1428InputParameters::addParam<MultiMooseEnum>(
const std::string & ,
1429 const std::string & )
1431 mooseError(
"You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1432 "is not required!");
1437InputParameters::addParam<std::vector<MooseEnum>>(
const std::string & ,
1438 const std::string & )
1440 mooseError(
"You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1441 "parameter is not required!");
1446InputParameters::addParam<std::vector<MultiMooseEnum>>(
const std::string & ,
1447 const std::string & )
1450 "You must supply a vector of MultiMooseEnum object(s) when using addParam, even if the "
1451 "parameter is not required!");
1456InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
const std::string & ,
1457 const std::string & )
1459 mooseError(
"You must supply a vector of MultiMooseEnum object(s) when using addRequiredParam!");
1464InputParameters::addPrivateParam<MooseEnum>(
const std::string & )
1466 mooseError(
"You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1467 "is not required!");
1472InputParameters::addPrivateParam<MultiMooseEnum>(
const std::string & )
1474 mooseError(
"You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1475 "parameter is not required!");
1480InputParameters::addDeprecatedParam<MooseEnum>(
const std::string & ,
1481 const std::string & ,
1482 const std::string & )
1484 mooseError(
"You must supply a MooseEnum object and the deprecation string when using "
1485 "addDeprecatedParam, even if the parameter is not required!");
1490InputParameters::addDeprecatedParam<MultiMooseEnum>(
const std::string & ,
1491 const std::string & ,
1492 const std::string & )
1494 mooseError(
"You must supply a MultiMooseEnum object and the deprecation string when using "
1495 "addDeprecatedParam, even if the parameter is not required!");
1500InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1501 const std::string & ,
1502 const std::string & ,
1503 const std::string & )
1505 mooseError(
"You must supply a vector of MooseEnum object(s) and the deprecation string when "
1506 "using addDeprecatedParam, even if the parameter is not required!");
1511InputParameters::setParamHelper<PostprocessorName, Real>(
const std::string & ,
1512 PostprocessorName & l_value,
1513 const Real & r_value)
1516 std::ostringstream oss;
1518 l_value = oss.str();
1523InputParameters::setParamHelper<PostprocessorName, int>(
const std::string & ,
1524 PostprocessorName & l_value,
1525 const int & r_value)
1528 std::ostringstream oss;
1530 l_value = oss.str();
1535InputParameters::setParamHelper<FunctionName, Real>(
const std::string & ,
1536 FunctionName & l_value,
1537 const Real & r_value)
1540 std::ostringstream oss;
1542 l_value = oss.str();
1547InputParameters::setParamHelper<FunctionName, int>(
const std::string & ,
1548 FunctionName & l_value,
1549 const int & r_value)
1552 std::ostringstream oss;
1554 l_value = oss.str();
1559InputParameters::setParamHelper<MaterialPropertyName, Real>(
const std::string & ,
1560 MaterialPropertyName & l_value,
1561 const Real & r_value)
1564 std::ostringstream oss;
1566 l_value = oss.str();
1571InputParameters::setParamHelper<MaterialPropertyName, int>(
const std::string & ,
1572 MaterialPropertyName & l_value,
1573 const int & r_value)
1576 std::ostringstream oss;
1578 l_value = oss.str();
1583InputParameters::setParamHelper<MooseFunctorName, Real>(
const std::string & ,
1584 MooseFunctorName & l_value,
1585 const Real & r_value)
1588 std::ostringstream oss;
1590 l_value = oss.str();
1595InputParameters::setParamHelper<MooseFunctorName, int>(
const std::string & ,
1596 MooseFunctorName & l_value,
1597 const int & r_value)
1600 std::ostringstream oss;
1602 l_value = oss.str();
1607InputParameters::getParamHelper<MooseEnum>(
const std::string & name_in,
1616InputParameters::getParamHelper<MultiMooseEnum>(
const std::string & name_in,
1625 const std::set<std::string> & reserved)
1628 _params[name]._reserved_values = reserved;
1631std::set<std::string>
1637 return std::set<std::string>();
1638 return it->second._reserved_values;
1645 return hit_node->fileLocation(
false);
1653 return hit_node->fullpath();
1665 const hit::Node & node,
1668 mooseAssert(node.type() == hit::NodeType::Field,
"Must be a field");
1676 return hit_node->fileLocation(
false);
1684 return hit_node->fullpath();
1691 const static pcrecpp::RE valid(
"[\\w:/]+");
1692 if (!valid.FullMatch(name))
1693 mooseError(
"Invalid parameter name: '", name,
"'");
1702 return it->second._ignore;
1703 mooseError(
"Parameter ", name,
" does not exist");
1706std::set<std::string>
1709 std::set<std::string> names;
1711 if (it->second._group == group)
1712 names.emplace(it->first);
1716std::set<std::string>
1719 std::set<std::string> param_set;
1721 param_set.emplace(it->first);
1725std::set<std::string>
1728 std::set<std::string> controllable;
1730 if (it->second._controllable)
1731 controllable.emplace(it->first);
1732 return controllable;
1738 auto prefix = param +
":";
1748 return hit_node->strVal();
1754 const std::string & moose_object_with_var_param_name)
const
1757 std::string variable_name =
getMooseType(var_param_name);
1758 if (variable_name ==
"")
1768 moose_object_with_var_param_name,
1769 "' while retrieving value for '",
1771 "' parameter! Did you forget to set '",
1773 "' or set it to '' (empty string) by accident?");
1777 variable_name = vec[0];
1780 return variable_name;
1785 const std::string & new_name,
1786 const std::string & docstring,
1787 const std::string & removal_date)
1789 auto params_it =
_params.find(old_name);
1790 if (params_it ==
_params.end())
1791 mooseError(
"Requested to rename parameter '",
1793 "' but that parameter name doesn't exist in the parameters object.");
1794 mooseAssert(params_it->second._deprecation_message.empty(),
1795 "Attempting to rename the parameter, '" << old_name <<
"', that is deprecated");
1797 auto new_metadata = std::move(params_it->second);
1798 if (!docstring.empty())
1799 new_metadata._doc_string = docstring;
1800 _params.emplace(new_name, std::move(new_metadata));
1803 auto values_it =
_values.find(old_name);
1804 auto new_value = std::move(values_it->second);
1805 _values.emplace(new_name, std::move(new_value));
1808 std::string deprecation_message;
1809 if (!removal_date.empty())
1810 deprecation_message =
"'" + old_name +
"' has been deprecated and will be removed on " +
1811 removal_date +
". Please use '" + new_name +
"' instead.";
1819 const std::string & new_name,
1820 const std::string & docstring,
1821 const std::string & removal_date)
1825 mooseError(
"Requested to rename coupled variable '",
1827 "' but that coupled variable name doesn't exist in the parameters object.");
1837 const std::string & new_name,
1838 const std::string & new_docstring)
1845 const std::string & new_name,
1846 const std::string & new_docstring)
1853 const std::string & new_name,
1854 const std::string & removal_date)
1861 const std::string & new_name,
1862 const std::string & removal_date)
1871 return it->second.first;
1876std::vector<std::string>
1880 "The parameter we are searching for aliases for should exist in our parameter map");
1881 std::vector<std::string> aliases = {param_name};
1884 aliases.push_back(pr.second);
1889std::optional<Moose::DataFileUtils::Path>
1895std::optional<std::string>
1897 const hit::Node & node,
1901 bool has_name =
false;
1903 bool has_default =
false;
1909 for (
const auto i : index_range(names))
1911 auto & name = names[i];
1913 if (MooseUtils::convert<Real>(name, real_value,
false))
1925 return {
"invalid value for '" + node.fullpath() +
1926 "': coupled vectors where some parameters are reals and others are variables are not "
1936std::pair<std::string, const hit::Node *>
1939 const hit::Node * node =
nullptr;
1941 std::string fullpath;
1943 if (
const hit::Node * param_node =
getHitNode(param))
1945 fullpath = param_node->fullpath();
1949 else if (
const hit::Node * block_node =
getHitNode())
1952 fullpath = block_node->fullpath() +
"/" + param;
1958 return {fullpath +
": ", node};
1972 const bool with_prefix ,
1973 const hit::Node * node ,
1974 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.