www.mooseframework.org
InputParameters.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "InputParameters.h"
11 
12 // MOOSE includes
13 #include "MooseEnum.h"
14 #include "MooseTypes.h"
15 #include "MooseUtils.h"
16 #include "MultiMooseEnum.h"
17 #include "ExecFlagEnum.h"
18 #include "MooseObject.h"
19 
20 #include "libmesh/utility.h"
21 #include "libmesh/simple_range.h"
22 
23 #include "pcrecpp.h"
24 
25 #include <cmath>
26 
29 {
30  InputParameters params;
31  return params;
32 }
33 
35  : Parameters(),
36  _collapse_nesting(false),
37  _moose_object_syntax_visibility(true),
38  _show_deprecated_message(true),
39  _allow_copy(true)
40 {
41 }
42 
44  : Parameters(), _show_deprecated_message(true), _allow_copy(true)
45 {
46  *this = rhs;
47 }
48 
49 InputParameters::InputParameters(const Parameters & rhs)
50  : _show_deprecated_message(true), _allow_copy(true)
51 {
52  _params.clear();
54  _collapse_nesting = false;
56 }
57 
58 void
60 {
61  Parameters::clear();
62  _params.clear();
63  _coupled_vars.clear();
65  _collapse_nesting = false;
68  _allow_copy = true;
69  _block_fullpath = "";
70  _block_location = "";
72  _new_to_old_names.clear();
73 }
74 
75 void
76 InputParameters::addClassDescription(const std::string & doc_string)
77 {
78  _class_description = doc_string;
79 }
80 
81 void
82 InputParameters::set_attributes(const std::string & name_in, bool inserted_only)
83 {
84  const auto name = checkForRename(name_in);
85 
86  if (!inserted_only)
87  {
88  auto & metadata = _params[name];
95  metadata._set_by_add_param = false;
96 
97  // valid_params don't make sense for MooseEnums
98  if (!have_parameter<MooseEnum>(name) && !have_parameter<MultiMooseEnum>(name))
99  metadata._valid = true;
100  }
101 }
102 
103 bool
104 InputParameters::attemptPrintDeprecated(const std::string & name_in)
105 {
106  const auto name = checkForRename(name_in);
108  {
109  auto emit_deprecation_message =
110  [this](const auto & deprecated_name, const auto & deprecation_message)
111  {
112  // This is user-facing, no need for a backtrace
113  const auto current_show_trace = Moose::show_trace;
114  Moose::show_trace = false;
116  Moose::out, false, true, errorPrefix(deprecated_name), ":\n", deprecation_message, "\n");
117  Moose::show_trace = current_show_trace;
118  return true;
119  };
120 
121  if (_params.count(name) && !libmesh_map_find(_params, name)._deprecation_message.empty())
122  return emit_deprecation_message(name,
123  "The parameter '" + name + "' is deprecated.\n" +
124  libmesh_map_find(_params, name)._deprecation_message);
125  else if (auto it = _old_to_new_name_and_dep.find(name_in);
126  it != _old_to_new_name_and_dep.end() && !it->second.second.empty())
127  return emit_deprecation_message(name_in, it->second.second);
128  }
129  return false;
130 }
131 
132 std::string
134 {
135  return _class_description;
136 }
137 
140 {
141  // An error to help minimize the segmentation faults that occure when MooseObjects do not have the
142  // correct constructor
143  if (!rhs._allow_copy)
144  {
145  const std::string & name =
146  rhs.get<std::string>("_object_name"); // If _allow_parameter_copy is set then so is name
147  // (see InputParameterWarehouse::addInputParameters)
148  mooseError("Copying of the InputParameters object for the ",
149  name,
150  " object 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",
153  " MyObject::MyObject(const InputParameters & parameters);");
154  }
155 
157 
158  _params = rhs._params;
159 
166  _allow_copy = rhs._allow_copy;
171 
172  return *this;
173 }
174 
177 {
178  Parameters::operator+=(rhs);
179 
180  // TODO: this is not a proper merge - if a particular parameter exists in both this and rhs,
181  // then we should actually smartly merge both metadata structs before storing in this.
182  for (auto it = rhs._params.begin(); it != rhs._params.end(); ++it)
183  _params[it->first] = it->second;
184 
185  _buildable_types.insert(
186  _buildable_types.end(), rhs._buildable_types.begin(), rhs._buildable_types.end());
187  _buildable_rm_types.insert(
188  _buildable_rm_types.end(), rhs._buildable_rm_types.begin(), rhs._buildable_rm_types.end());
189 
190  // Collapse nesting and moose object syntax hiding are not modified with +=
191  _coupled_vars.insert(rhs._coupled_vars.begin(), rhs._coupled_vars.end());
194 
196  rhs._old_to_new_name_and_dep.end());
197  _new_to_old_names.insert(rhs._new_to_old_names.begin(), rhs._new_to_old_names.end());
198  return *this;
199 }
200 
201 void
202 InputParameters::setDeprecatedVarDocString(const std::string & new_name,
203  const std::string & doc_string)
204 {
205  auto coupled_vars_it = _new_to_deprecated_coupled_vars.find(new_name);
206  if (coupled_vars_it != _new_to_deprecated_coupled_vars.end())
207  {
208  auto params_it = _params.find(coupled_vars_it->second);
209  if (params_it == _params.end())
210  mooseError("There must have been a mistake in the construction of the new to deprecated "
211  "coupled vars map because the old name ",
212  coupled_vars_it->second,
213  " doesn't exist in the parameters data.");
214 
215  params_it->second._doc_string = doc_string;
216  }
217 }
218 
219 void
220 InputParameters::addCoupledVar(const std::string & name, Real value, const std::string & doc_string)
221 {
222  addParam<std::vector<VariableName>>(name, doc_string);
223  _coupled_vars.insert(name);
224  auto & metadata = _params[name];
225  metadata._coupled_default.assign(1, value);
226  metadata._have_coupled_default = true;
227 
228  // Set the doc string for any associated deprecated coupled var
229  setDeprecatedVarDocString(name, doc_string);
230 }
231 
232 void
233 InputParameters::addCoupledVar(const std::string & name,
234  const std::vector<Real> & value,
235  const std::string & doc_string)
236 {
237  // std::vector<VariableName>(1, Moose::stringify(value)),
238  addParam<std::vector<VariableName>>(name, doc_string);
239  _coupled_vars.insert(name);
240  auto & metadata = _params[name];
241  metadata._coupled_default = value;
242  metadata._have_coupled_default = true;
243 
244  // Set the doc string for any associated deprecated coupled var
245  setDeprecatedVarDocString(name, doc_string);
246 }
247 
248 void
249 InputParameters::addCoupledVar(const std::string & name, const std::string & doc_string)
250 {
251  addParam<std::vector<VariableName>>(name, doc_string);
252  _coupled_vars.insert(name);
253 
254  // Set the doc string for any associated deprecated coupled var
255  setDeprecatedVarDocString(name, doc_string);
256 }
257 
258 void
259 InputParameters::addDeprecatedCoupledVar(const std::string & old_name,
260  const std::string & new_name,
261  const std::string & removal_date /*=""*/)
262 {
263  mooseDeprecated("Please use 'deprecateCoupledVar'");
264 
265  _show_deprecated_message = false;
266 
267  // Set the doc string if we are adding the deprecated var after the new var has already been added
268  auto params_it = _params.find(new_name);
269  std::string doc_string;
270  if (params_it != _params.end())
271  doc_string = params_it->second._doc_string;
272 
273  addParam<std::vector<VariableName>>(old_name, doc_string);
274  _coupled_vars.insert(old_name);
275  _new_to_deprecated_coupled_vars.emplace(new_name, old_name);
276 
277  std::string deprecation_message =
278  "The coupled variable parameter '" + old_name + "' has been deprecated";
279  if (!removal_date.empty())
280  deprecation_message += " and will be removed " + removal_date;
281  deprecation_message += ". Please use the '" + new_name + "' coupled variable parameter instead.";
282  _params[old_name]._deprecation_message = deprecation_message;
284 }
285 
286 void
288  const std::string & base_name,
289  const std::string & num_name,
290  const std::string & doc_string)
291 {
292  addParam<std::vector<VariableName>>(name, doc_string);
293  _coupled_vars.insert(name);
294  _params[name]._autobuild_vecs = std::make_pair(base_name, num_name);
295 
296  // Additionally there are two more parameters that need to be added:
297  addParam<std::string>(base_name, doc_string + " (base_name)");
298  addParam<unsigned int>(num_name, doc_string + " (num_name)");
299 }
300 
301 void
303  const std::string & base_name,
304  const std::string & num_name,
305  const std::string & doc_string)
306 {
307  addRequiredParam<std::vector<VariableName>>(name, doc_string);
308 
309  addCoupledVarWithAutoBuild(name, base_name, num_name, doc_string);
310 }
311 
312 void
313 InputParameters::addRequiredCoupledVar(const std::string & name, const std::string & doc_string)
314 {
315  addRequiredParam<std::vector<VariableName>>(name, doc_string);
316  _coupled_vars.insert(name);
317 }
318 
319 std::string
320 InputParameters::getDocString(const std::string & name_in) const
321 {
322  const auto name = checkForRename(name_in);
323 
324  std::string doc_string;
325  auto it = _params.find(name);
326  if (it != _params.end())
327  for (const auto & ch : it->second._doc_string)
328  {
329  if (ch == '\n')
330  doc_string += " ... ";
331  else
332  doc_string += ch;
333  }
334 
335  return doc_string;
336 }
337 
338 void
339 InputParameters::setDocString(const std::string & name_in, const std::string & doc)
340 {
341  const auto name = checkForRename(name_in);
342 
343  auto it = _params.find(name);
344  if (it == _params.end())
345  mooseError("Unable to set the documentation string (using setDocString) for the \"",
346  name,
347  "\" parameter, the parameter does not exist.");
348  it->second._doc_string = doc;
349 }
350 
351 bool
352 InputParameters::isParamRequired(const std::string & name_in) const
353 {
354  const auto name = checkForRename(name_in);
355  return _params.count(name) > 0 && _params.at(name)._required;
356 }
357 
358 void
359 InputParameters::makeParamNotRequired(const std::string & name_in)
360 {
361  const auto name = checkForRename(name_in);
362 
363  if (_params.count(name))
364  _params[name]._required = false;
365 }
366 
367 bool
368 InputParameters::isParamValid(const std::string & name_in) const
369 {
370  const auto name = checkForRename(name_in);
371  if (have_parameter<MooseEnum>(name))
372  return get<MooseEnum>(name).isValid();
373  else if (have_parameter<std::vector<MooseEnum>>(name))
374  {
375  for (auto it = get<std::vector<MooseEnum>>(name).begin();
376  it != get<std::vector<MooseEnum>>(name).end();
377  ++it)
378  if (!it->isValid())
379  return false;
380  return true;
381  }
382  else if (have_parameter<MultiMooseEnum>(name))
383  return get<MultiMooseEnum>(name).isValid();
384  else if (have_parameter<ExecFlagEnum>(name))
385  return get<ExecFlagEnum>(name).isValid();
386  else
387  return _params.count(name) > 0 && _params.at(name)._valid;
388 }
389 
390 bool
391 InputParameters::isParamSetByAddParam(const std::string & name_in) const
392 {
393  const auto name = checkForRename(name_in);
394  return _params.count(name) > 0 && _params.at(name)._set_by_add_param;
395 }
396 
397 bool
398 InputParameters::isParamDeprecated(const std::string & name_in) const
399 {
400  const auto name = checkForRename(name_in);
401  return _params.count(name) > 0 && !_params.at(name)._deprecation_message.empty();
402 }
403 
404 bool
406 {
407  for (const auto & it : *this)
408  if (isParamRequired(it.first) && !isParamValid(it.first))
409  return false;
410  return true;
411 }
412 
413 bool
414 InputParameters::isPrivate(const std::string & name_in) const
415 {
416  const auto name = checkForRename(name_in);
417  return _params.count(name) > 0 && _params.at(name)._is_private;
418 }
419 
420 void
421 InputParameters::declareControllable(const std::string & input_names,
422  std::set<ExecFlagType> execute_flags)
423 {
424  std::vector<std::string> names;
425  MooseUtils::tokenize<std::string>(input_names, names, 1, " ");
426  for (auto & name_in : names)
427  {
428  const auto name = checkForRename(name_in);
429  auto map_iter = _params.find(name);
430  if (map_iter != _params.end()) // error is handled by checkParams method
431  {
432  map_iter->second._controllable = true;
433  map_iter->second._controllable_flags = execute_flags;
434  }
435  else
436  mooseError("The input parameter '",
437  name,
438  "' does not exist, thus cannot be marked as controllable.");
439  }
440 }
441 
442 bool
443 InputParameters::isControllable(const std::string & name_in) const
444 {
445  const auto name = checkForRename(name_in);
446  return _params.count(name) > 0 && _params.at(name)._controllable;
447 }
448 
449 const std::set<ExecFlagType> &
450 InputParameters::getControllableExecuteOnTypes(const std::string & name_in) const
451 {
452  const auto name = checkForRename(name_in);
453  return at(name)._controllable_flags;
454 }
455 
456 void
457 InputParameters::registerBase(const std::string & value)
458 {
459  InputParameters::set<std::string>("_moose_base") = value;
460  _params["_moose_base"]._is_private = true;
461 }
462 
463 void
465 {
466  InputParameters::set<std::string>("_moose_warehouse_system_name") = value;
467  _params["_moose_warehouse_system_name"]._is_private = true;
468 }
469 
470 const std::string &
472 {
473  mooseAssert(have_parameter<std::string>("_moose_warehouse_system_name"),
474  "SystemAttributeName is not available! Call 'registerSystemAttributeName' (usually "
475  "in the validParams function) before you try accessing it!");
476  return Parameters::get<std::string>("_moose_warehouse_system_name");
477 }
478 
479 void
480 InputParameters::registerBuildableTypes(const std::string & names)
481 {
482  _buildable_types.clear();
483  MooseUtils::tokenize(names, _buildable_types, 1, " \t\n\v\f\r"); // tokenize on whitespace
484 }
485 
486 void
488  const std::string & name,
490  Moose::RelationshipManagerInputParameterCallback input_parameter_callback)
491 {
492  _buildable_rm_types.emplace_back(name, rm_type, input_parameter_callback);
493 }
494 
495 const std::vector<std::string> &
497 {
498  return _buildable_types;
499 }
500 
501 const std::vector<std::tuple<std::string,
505 {
506  return _buildable_rm_types;
507 }
508 
509 void
511 {
512  _collapse_nesting = collapse;
513 }
514 
515 bool
517 {
518  return _collapse_nesting;
519 }
520 
521 void
523 {
524  _moose_object_syntax_visibility = visibility;
525 }
526 
527 bool
529 {
531 }
532 
533 #define dynamicCastRangeCheck(type, up_type, long_name, short_name, param, oss) \
534  do \
535  { \
536  libMesh::Parameters::Value * val = MooseUtils::get(param); \
537  InputParameters::Parameter<type> * scalar_p = \
538  dynamic_cast<InputParameters::Parameter<type> *>(val); \
539  if (scalar_p) \
540  rangeCheck<type, up_type>(long_name, short_name, scalar_p, oss); \
541  InputParameters::Parameter<std::vector<type>> * vector_p = \
542  dynamic_cast<InputParameters::Parameter<std::vector<type>> *>(val); \
543  if (vector_p) \
544  rangeCheck<type, up_type>(long_name, short_name, vector_p, oss); \
545  } while (0)
546 
547 #define checkMooseType(param_type, name) \
548  if (have_parameter<param_type>(name) || have_parameter<std::vector<param_type>>(name)) \
549  oss << inputLocation(param_name) << ": non-controllable type '" << type(name) \
550  << "' for parameter '" << paramFullpath(param_name) << "' marked controllable";
551 
552 void
553 InputParameters::checkParams(const std::string & parsing_syntax)
554 {
555  std::string parampath = blockFullpath() != "" ? blockFullpath() : parsing_syntax;
556  std::ostringstream oss;
557  // Required parameters
558  for (const auto & it : *this)
559  {
560  const auto param_name = checkForRename(it.first);
561  if (!isParamValid(param_name) && isParamRequired(param_name))
562  {
563  // check if an old, deprecated name exists for this parameter that may be specified
564  auto oit = _new_to_deprecated_coupled_vars.find(param_name);
565  if (oit != _new_to_deprecated_coupled_vars.end() && isParamValid(oit->second))
566  continue;
567 
568  oss << blockLocation() << ": missing required parameter '" << parampath + "/" + param_name
569  << "'\n";
570  oss << "\tDoc String: \"" + getDocString(param_name) + "\"" << std::endl;
571  }
572  }
573 
574  // Range checked parameters
575  for (const auto & it : *this)
576  {
577  std::string long_name(parampath + "/" + it.first);
578 
579  dynamicCastRangeCheck(Real, Real, long_name, it.first, it.second, oss);
580  dynamicCastRangeCheck(int, long, long_name, it.first, it.second, oss);
581  dynamicCastRangeCheck(long, long, long_name, it.first, it.second, oss);
582  dynamicCastRangeCheck(unsigned int, long, long_name, it.first, it.second, oss);
583  }
584 
585  // Controllable parameters
586  for (const auto & param_name : getControllableParameters())
587  {
588  if (isPrivate(param_name))
589  oss << inputLocation(param_name) << ": private parameter '" << paramFullpath(param_name)
590  << "' marked controllable";
591 
592  checkMooseType(NonlinearVariableName, param_name);
593  checkMooseType(AuxVariableName, param_name);
594  checkMooseType(VariableName, param_name);
595  checkMooseType(BoundaryName, param_name);
596  checkMooseType(SubdomainName, param_name);
597  checkMooseType(PostprocessorName, param_name);
598  checkMooseType(VectorPostprocessorName, param_name);
599  checkMooseType(UserObjectName, param_name);
600  checkMooseType(MaterialPropertyName, param_name);
601  }
602 
603  if (!oss.str().empty())
604  mooseError(oss.str());
605 }
606 
607 bool
608 InputParameters::isRangeChecked(const std::string & param_name) const
609 {
610  const auto name = checkForRename(param_name);
611  return !_params.find(name)->second._range_function.empty();
612 }
613 
614 std::string
615 InputParameters::rangeCheckedFunction(const std::string & param_name) const
616 {
617  const auto name = checkForRename(param_name);
618  return _params.at(name)._range_function;
619 }
620 
621 bool
622 InputParameters::hasDefault(const std::string & param_name) const
623 {
624  const auto name = checkForRename(param_name);
626  return true;
627  // If it has a default, it's already valid
628  else if (isParamSetByAddParam(name))
629  return true;
630  else if (isParamValid(name))
631  mooseError("No way to know if the parameter", param_name, "has a default");
632  else
633  return false;
634 }
635 
636 bool
637 InputParameters::hasCoupledValue(const std::string & coupling_name) const
638 {
639  return _coupled_vars.find(coupling_name) != _coupled_vars.end();
640 }
641 
642 bool
643 InputParameters::hasDefaultCoupledValue(const std::string & coupling_name) const
644 {
645  return _params.count(coupling_name) > 0 && _params.at(coupling_name)._have_coupled_default &&
646  _coupled_vars.count(coupling_name) > 0;
647 }
648 
649 void
650 InputParameters::defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i)
651 {
652  _params[coupling_name]._coupled_default.resize(i + 1);
653  _params[coupling_name]._coupled_default[i] = value;
654  _params[coupling_name]._have_coupled_default = true;
655 }
656 
657 Real
658 InputParameters::defaultCoupledValue(const std::string & coupling_name, unsigned int i) const
659 {
660  auto value_it = _params.find(coupling_name);
661 
662  if (value_it == _params.end() || !value_it->second._have_coupled_default)
663  mooseError("Attempted to retrieve default value for coupled variable '",
664  coupling_name,
665  "' when none was provided. \n\nThere are three reasons why this may have "
666  "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
667  "to provide a default value. \n 2. This should have been a required coupled "
668  "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
669  "coupled value should have been properly guarded with isCoupled()\n");
670 
671  return value_it->second._coupled_default.at(i);
672 }
673 
674 unsigned int
675 InputParameters::numberDefaultCoupledValues(const std::string & coupling_name) const
676 {
677  auto value_it = _params.find(coupling_name);
678  if (value_it == _params.end())
679  mooseError("Attempted to retrieve default value for coupled variable '",
680  coupling_name,
681  "' when none was provided.");
682  return value_it->second._coupled_default.size();
683 }
684 
685 std::map<std::string, std::pair<std::string, std::string>>
687 {
688  std::map<std::string, std::pair<std::string, std::string>> abv;
689  for (auto it = _params.begin(); it != _params.end(); ++it)
690  {
691  if (!it->second._autobuild_vecs.first.empty())
692  abv[it->first] = it->second._autobuild_vecs;
693  }
694  return abv;
695 }
696 
697 std::string
698 InputParameters::type(const std::string & name_in) const
699 {
700  const auto name = checkForRename(name_in);
701  if (!_values.count(name))
702  mooseError("Parameter \"", name, "\" not found.\n\n", *this);
703 
704  if (_coupled_vars.find(name) != _coupled_vars.end())
705  return "std::vector<VariableName>";
706  else if (_params.count(name) > 0 && !_params.at(name)._custom_type.empty())
707  return _params.at(name)._custom_type;
708  return _values.at(name)->type();
709 }
710 
711 std::string
712 InputParameters::getMooseType(const std::string & name_in) const
713 {
714  const auto name = checkForRename(name_in);
715  std::string var;
716 
717  if (have_parameter<VariableName>(name))
718  var = get<VariableName>(name);
719  else if (have_parameter<NonlinearVariableName>(name))
720  var = get<NonlinearVariableName>(name);
721  else if (have_parameter<AuxVariableName>(name))
722  var = get<AuxVariableName>(name);
723  else if (have_parameter<PostprocessorName>(name))
724  var = get<PostprocessorName>(name);
725  else if (have_parameter<VectorPostprocessorName>(name))
726  var = get<VectorPostprocessorName>(name);
727  else if (have_parameter<FunctionName>(name))
728  var = get<FunctionName>(name);
729  else if (have_parameter<UserObjectName>(name))
730  var = get<UserObjectName>(name);
731  else if (have_parameter<MaterialPropertyName>(name))
732  var = get<MaterialPropertyName>(name);
733  else if (have_parameter<std::string>(name))
734  var = get<std::string>(name);
735 
736  return var;
737 }
738 
739 std::vector<std::string>
740 InputParameters::getVecMooseType(const std::string & name_in) const
741 {
742  const auto name = checkForRename(name_in);
743  std::vector<std::string> svars;
744 
745  if (have_parameter<std::vector<VariableName>>(name))
746  {
747  std::vector<VariableName> vars = get<std::vector<VariableName>>(name);
748  std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
749  }
750  else if (have_parameter<std::vector<NonlinearVariableName>>(name))
751  {
752  std::vector<NonlinearVariableName> vars = get<std::vector<NonlinearVariableName>>(name);
753  std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
754  }
755  else if (have_parameter<std::vector<AuxVariableName>>(name))
756  {
757  std::vector<AuxVariableName> vars = get<std::vector<AuxVariableName>>(name);
758  std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
759  }
760  else if (have_parameter<std::vector<MaterialPropertyName>>(name))
761  {
762  std::vector<MaterialPropertyName> vars = get<std::vector<MaterialPropertyName>>(name);
763  std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
764  }
765  else if (have_parameter<std::vector<std::string>>(name))
766  {
767  std::vector<std::string> vars = get<std::vector<std::string>>(name);
768  std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
769  }
770 
771  return svars;
772 }
773 
774 void
775 InputParameters::addParamNamesToGroup(const std::string & space_delim_names,
776  const std::string group_name)
777 {
778  std::vector<std::string> elements;
779  MooseUtils::tokenize(space_delim_names, elements, 1, " \t\n\v\f\r"); // tokenize on whitespace
780 
781  // Since we don't require types (templates) for this method, we need
782  // to get a raw list of parameter names to compare against.
783  std::set<std::string> param_names;
784  for (const auto & it : *this)
785  param_names.insert(it.first);
786 
787  for (const auto & param_name : elements)
788  if (_params.count(param_name) > 0)
789  _params[param_name]._group = group_name;
790  else
791  mooseError("Unable to find a parameter with name: ",
792  param_name,
793  " when adding to group ",
794  group_name,
795  '.');
796 }
797 
798 bool
799 InputParameters::isCommandLineParameter(const std::string & name) const
800 {
801  return at(checkForRename(name))._cl_data.has_value();
802 }
803 
804 const std::vector<std::string> &
805 InputParameters::getCommandLineSyntax(const std::string & name) const
806 {
808 }
809 
811 InputParameters::getCommandLineArgumentType(const std::string & name) const
812 {
814 }
815 
816 std::string
817 InputParameters::getGroupName(const std::string & param_name_in) const
818 {
819  const auto param_name = checkForRename(param_name_in);
820  auto it = _params.find(param_name);
821  if (it != _params.end())
822  return it->second._group;
823  return std::string();
824 }
825 
826 void
828  const std::vector<std::string> exclude)
829 {
830  // Loop through the common parameters
831  for (const auto & it : common)
832  {
833  // Common parameter name
834  const std::string & common_name = it.first;
835  // Continue to next parameter, if the current is in list of excluded parameters
836  if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
837  continue;
838 
839  applyParameter(common, common_name);
840  }
841 
842  // Loop through the coupled variables
843  for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
844  it != common.coupledVarsEnd();
845  ++it)
846  {
847  // Variable name
848  const std::string var_name = *it;
849 
850  // Continue to next variable, if the current is in list of excluded parameters
851  if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
852  continue;
853 
854  applyCoupledVar(common, var_name);
855  }
856 }
857 
858 void
860  const std::vector<std::string> & include,
861  bool allow_private)
862 {
863  // Loop through the common parameters
864  for (const auto & it : common)
865  {
866 
867  // Common parameter name
868  const std::string & common_name = it.first;
869 
870  // Continue to next parameter, if the current is not in list of included parameters
871  if (std::find(include.begin(), include.end(), common_name) == include.end())
872  continue;
873 
874  applyParameter(common, common_name, allow_private);
875  }
876 
877  // Loop through the coupled variables
878  for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
879  it != common.coupledVarsEnd();
880  ++it)
881  {
882  // Variable name
883  const std::string var_name = *it;
884 
885  // Continue to next variable, if the current is not in list of included parameters
886  if (std::find(include.begin(), include.end(), var_name) == include.end())
887  continue;
888 
889  applyCoupledVar(common, var_name);
890  }
891 }
892 
893 void
894 InputParameters::applyCoupledVar(const InputParameters & common, const std::string & var_name)
895 {
896  // Disable the display of deprecated message when applying common parameters, this avoids a dump
897  // of messages
898  _show_deprecated_message = false;
899 
900  // If the local parameters has a coupled variable, populate it with the value from the common
901  // parameters, if the common parameters has the coupled variable too
902  if (hasCoupledValue(var_name))
903  {
904  if (common.hasDefaultCoupledValue(var_name))
905  {
906  // prepare a vector of default coupled values
907  std::vector<Real> defaults(common.numberDefaultCoupledValues(var_name));
908  for (unsigned int j = 0; j < common.numberDefaultCoupledValues(var_name); ++j)
909  defaults[j] = common.defaultCoupledValue(var_name, j);
910  addCoupledVar(var_name, defaults, common.getDocString(var_name));
911  }
912  else if (common.hasCoupledValue(var_name))
913  addCoupledVar(var_name, common.getDocString(var_name));
914  }
915 
916  // Enable deprecated message printing
918 }
919 
920 void
922  const std::string & common_name,
923  bool allow_private)
924 {
925  // Disable the display of deprecated message when applying common parameters, this avoids a dump
926  // of messages
927  _show_deprecated_message = false;
928 
929  const auto local_name = checkForRename(common_name);
930 
931  // Extract the properties from the local parameter for the current common parameter name
932  const bool local_exist = _values.find(local_name) != _values.end();
933  const bool local_set = _params.count(local_name) > 0 && !_params[local_name]._set_by_add_param;
934  const bool local_priv = allow_private ? false : isPrivate(local_name);
935  const bool local_valid = isParamValid(local_name);
936 
937  // Extract the properties from the common parameter
938  const bool common_exist = common._values.find(common_name) != common._values.end();
939  const bool common_priv = allow_private ? false : common.isPrivate(common_name);
940  const bool common_valid = common.isParamValid(common_name);
941 
942  /* In order to apply a common parameter 4 statements must be satisfied
943  * (1) A local parameter must exist with the same name as the common parameter
944  * (2) Common parameter must be valid and exist
945  * (3) Local parameter must be invalid OR not have been set from its default
946  * (4) Both cannot be private
947  */
948  if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
949  (!common_priv || !local_priv))
950  {
951  remove(local_name);
952  _values[local_name] = common._values.find(common_name)->second->clone();
953  set_attributes(local_name, false);
954  _params[local_name]._set_by_add_param =
955  libmesh_map_find(common._params, common_name)._set_by_add_param;
956  }
957 
958  // Enable deprecated message printing
960 }
961 
963 bool
964 InputParameters::paramSetByUser(const std::string & name) const
965 {
966  mooseDeprecated("paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
967  return isParamSetByUser(name);
968 }
969 
970 bool
971 InputParameters::isParamSetByUser(const std::string & name_in) const
972 {
973  const auto name = checkForRename(name_in);
974  if (!isParamValid(name))
975  // if the parameter is invalid, it is for sure not set by the user
976  return false;
977  else
978  // If the parameters is not located in the list, then it was set by the user
979  // If the parameter is private, and present in global params, it is ignored, therefore not set
980  return _params.count(name) > 0 && !_params.at(name)._set_by_add_param &&
981  !_params.at(name)._is_private;
982 }
983 
984 const std::string &
985 InputParameters::getDescription(const std::string & name_in) const
986 {
987  const auto name = checkForRename(name_in);
988  auto it = _params.find(name);
989  if (it == _params.end())
990  mooseError("No parameter exists with the name ", name);
991  return it->second._doc_string;
992 }
993 
994 template <>
995 void
996 InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
997  const MooseEnum & moose_enum,
998  const std::string & doc_string)
999 {
1000  InputParameters::set<MooseEnum>(name) = moose_enum; // valid parameter is set by set_attributes
1001  auto & metadata = _params[name];
1002  metadata._required = true;
1003  metadata._doc_string = doc_string;
1004 }
1005 
1006 template <>
1007 void
1008 InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1009  const MultiMooseEnum & moose_enum,
1010  const std::string & doc_string)
1011 {
1012  InputParameters::set<MultiMooseEnum>(name) =
1013  moose_enum; // valid parameter is set by set_attributes
1014  auto & metadata = _params[name];
1015  metadata._required = true;
1016  metadata._doc_string = doc_string;
1017 }
1018 
1019 template <>
1020 void
1021 InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1022  const std::string & name,
1023  const std::vector<MooseEnum> & moose_enums,
1024  const std::string & doc_string)
1025 {
1026  InputParameters::set<std::vector<MooseEnum>>(name) =
1027  moose_enums; // valid parameter is set by set_attributes
1028  auto & metadata = _params[name];
1029  metadata._required = true;
1030  metadata._doc_string = doc_string;
1031 }
1032 
1033 template <>
1034 void
1035 InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1036  const std::string & /*doc_string*/)
1037 {
1038  mooseError("You must supply a MooseEnum object when using addParam, even if the parameter is not "
1039  "required!");
1040 }
1041 
1042 template <>
1043 void
1044 InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1045  const std::string & /*doc_string*/)
1046 {
1047  mooseError("You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1048  "is not required!");
1049 }
1050 
1051 template <>
1052 void
1053 InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1054  const std::string & /*doc_string*/)
1055 {
1056  mooseError("You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1057  "parameter is not required!");
1058 }
1059 
1060 template <>
1061 void
1062 InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/)
1063 {
1064  mooseError("You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1065  "is not required!");
1066 }
1067 
1068 template <>
1069 void
1070 InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/)
1071 {
1072  mooseError("You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1073  "parameter is not required!");
1074 }
1075 
1076 template <>
1077 void
1078 InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
1079  const std::string & /*doc_string*/,
1080  const std::string & /*deprecation_message*/)
1081 {
1082  mooseError("You must supply a MooseEnum object and the deprecation string when using "
1083  "addDeprecatedParam, even if the parameter is not required!");
1084 }
1085 
1086 template <>
1087 void
1088 InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
1089  const std::string & /*doc_string*/,
1090  const std::string & /*deprecation_message*/)
1091 {
1092  mooseError("You must supply a MultiMooseEnum object and the deprecation string when using "
1093  "addDeprecatedParam, even if the parameter is not required!");
1094 }
1095 
1096 template <>
1097 void
1098 InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1099  const std::string & /*name*/,
1100  const std::string & /*doc_string*/,
1101  const std::string & /*deprecation_message*/)
1102 {
1103  mooseError("You must supply a vector of MooseEnum object(s) and the deprecation string when "
1104  "using addDeprecatedParam, even if the parameter is not required!");
1105 }
1106 
1107 std::string
1108 InputParameters::appendFunctorDescription(const std::string & doc_string) const
1109 {
1110  return MooseUtils::trim(doc_string, ". ") +
1111  ". A functor is any of the following: a variable, a functor material property, a "
1112  "function, a post-processor, or a number.";
1113 }
1114 
1115 template <>
1116 void
1117 InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & /*name*/,
1118  PostprocessorName & l_value,
1119  const Real & r_value)
1120 {
1121  // Assign the default value so that it appears in the dump
1122  std::ostringstream oss;
1123  oss << r_value;
1124  l_value = oss.str();
1125 }
1126 
1127 template <>
1128 void
1129 InputParameters::setParamHelper<PostprocessorName, int>(const std::string & /*name*/,
1130  PostprocessorName & l_value,
1131  const int & r_value)
1132 {
1133  // Assign the default value so that it appears in the dump
1134  std::ostringstream oss;
1135  oss << r_value;
1136  l_value = oss.str();
1137 }
1138 
1139 template <>
1140 void
1141 InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1142  FunctionName & l_value,
1143  const Real & r_value)
1144 {
1145  // Assign the default value so that it appears in the dump
1146  std::ostringstream oss;
1147  oss << r_value;
1148  l_value = oss.str();
1149 }
1150 
1151 template <>
1152 void
1153 InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1154  FunctionName & l_value,
1155  const int & r_value)
1156 {
1157  // Assign the default value so that it appears in the dump
1158  std::ostringstream oss;
1159  oss << r_value;
1160  l_value = oss.str();
1161 }
1162 
1163 template <>
1164 void
1165 InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1166  MaterialPropertyName & l_value,
1167  const Real & r_value)
1168 {
1169  // Assign the default value so that it appears in the dump
1170  std::ostringstream oss;
1171  oss << r_value;
1172  l_value = oss.str();
1173 }
1174 
1175 template <>
1176 void
1177 InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1178  MaterialPropertyName & l_value,
1179  const int & r_value)
1180 {
1181  // Assign the default value so that it appears in the dump
1182  std::ostringstream oss;
1183  oss << r_value;
1184  l_value = oss.str();
1185 }
1186 
1187 template <>
1188 void
1189 InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
1190  MooseFunctorName & l_value,
1191  const Real & r_value)
1192 {
1193  // Assign the default value so that it appears in the dump
1194  std::ostringstream oss;
1195  oss << r_value;
1196  l_value = oss.str();
1197 }
1198 
1199 template <>
1200 void
1201 InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
1202  MooseFunctorName & l_value,
1203  const int & r_value)
1204 {
1205  // Assign the default value so that it appears in the dump
1206  std::ostringstream oss;
1207  oss << r_value;
1208  l_value = oss.str();
1209 }
1210 
1211 template <>
1212 const MooseEnum &
1213 InputParameters::getParamHelper<MooseEnum>(const std::string & name_in,
1214  const InputParameters & pars,
1215  const MooseEnum *,
1216  const MooseObject * /* = nullptr */)
1217 {
1218  const auto name = pars.checkForRename(name_in);
1219  return pars.get<MooseEnum>(name);
1220 }
1221 
1222 template <>
1223 const MultiMooseEnum &
1224 InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name_in,
1225  const InputParameters & pars,
1226  const MultiMooseEnum *,
1227  const MooseObject * /* = nullptr */)
1228 {
1229  const auto name = pars.checkForRename(name_in);
1230  return pars.get<MultiMooseEnum>(name);
1231 }
1232 
1233 void
1234 InputParameters::setReservedValues(const std::string & name_in,
1235  const std::set<std::string> & reserved)
1236 {
1237  const auto name = checkForRename(name_in);
1238  _params[name]._reserved_values = reserved;
1239 }
1240 
1241 std::set<std::string>
1242 InputParameters::reservedValues(const std::string & name_in) const
1243 {
1244  const auto name = checkForRename(name_in);
1245  auto it = _params.find(name);
1246  if (it == _params.end())
1247  return std::set<std::string>();
1248  return it->second._reserved_values;
1249 }
1250 
1251 void
1252 InputParameters::checkParamName(const std::string & name) const
1253 {
1254  const static pcrecpp::RE valid("[\\w:/]+");
1255  if (!valid.FullMatch(name))
1256  mooseError("Invalid parameter name: '", name, "'");
1257 }
1258 
1260 InputParameters::getCommandLineMetadata(const std::string & name) const
1261 {
1262  const auto & cl_data = at(checkForRename(name))._cl_data;
1263  if (!cl_data)
1264  mooseError("The parameter '", name, "' is not a command line parameter.");
1265  return *cl_data;
1266 }
1267 
1268 bool
1269 InputParameters::shouldIgnore(const std::string & name_in)
1270 {
1271  const auto name = checkForRename(name_in);
1272  auto it = _params.find(name);
1273  if (it != _params.end())
1274  return it->second._ignore;
1275  mooseError("Parameter ", name, " does not exist");
1276 }
1277 
1278 std::set<std::string>
1279 InputParameters::getGroupParameters(const std::string & group) const
1280 {
1281  std::set<std::string> names;
1282  for (auto it = _params.begin(); it != _params.end(); ++it)
1283  if (it->second._group == group)
1284  names.emplace(it->first);
1285  return names;
1286 }
1287 
1288 std::set<std::string>
1290 {
1291  std::set<std::string> param_set;
1292  for (auto it = _params.begin(); it != _params.end(); ++it)
1293  param_set.emplace(it->first);
1294  return param_set;
1295 }
1296 
1297 std::set<std::string>
1299 {
1300  std::set<std::string> controllable;
1301  for (auto it = _params.begin(); it != _params.end(); ++it)
1302  if (it->second._controllable)
1303  controllable.emplace(it->first);
1304  return controllable;
1305 }
1306 
1307 std::string
1308 InputParameters::errorPrefix(const std::string & param) const
1309 {
1310  auto prefix = param + ":";
1311  if (!inputLocation(param).empty())
1312  prefix = inputLocation(param) + ": (" + paramFullpath(param) + ")";
1313  return prefix;
1314 }
1315 
1316 std::string
1317 InputParameters::varName(const std::string & var_param_name,
1318  const std::string & moose_object_with_var_param_name) const
1319 {
1320  // Try the scalar version first
1321  std::string variable_name = getMooseType(var_param_name);
1322  if (variable_name == "")
1323  {
1324  auto vec = getVecMooseType(var_param_name);
1325 
1326  // Catch the (very unlikely) case where a user specifies
1327  // variable = '' (the empty string)
1328  // in their input file. This could happen if e.g. something goes
1329  // wrong with dollar bracket expression expansion.
1330  if (vec.empty())
1331  mooseError("Error constructing object '",
1332  moose_object_with_var_param_name,
1333  "' while retrieving value for '",
1334  var_param_name,
1335  "' parameter! Did you forget to set '",
1336  var_param_name,
1337  "' or set it to '' (empty string) by accident?");
1338 
1339  // When using vector variables, we are only going to use the first one in the list at the
1340  // interface level...
1341  variable_name = vec[0];
1342  }
1343 
1344  return variable_name;
1345 }
1346 
1347 void
1348 InputParameters::renameParamInternal(const std::string & old_name,
1349  const std::string & new_name,
1350  const std::string & docstring,
1351  const std::string & removal_date)
1352 {
1353  auto params_it = _params.find(old_name);
1354  if (params_it == _params.end())
1355  mooseError("Requested to rename parameter '",
1356  old_name,
1357  "' but that parameter name doesn't exist in the parameters object.");
1358 
1359  auto new_metadata = std::move(params_it->second);
1360  if (!docstring.empty())
1361  new_metadata._doc_string = docstring;
1362  else
1363  new_metadata._doc_string = params_it->second._doc_string;
1364  _params.emplace(new_name, std::move(new_metadata));
1365  _params.erase(params_it);
1366 
1367  auto values_it = _values.find(old_name);
1368  auto new_value = std::move(values_it->second);
1369  _values.emplace(new_name, std::move(new_value));
1370  _values.erase(values_it);
1371 
1372  std::string deprecation_message;
1373  if (!removal_date.empty())
1374  deprecation_message = "'" + old_name + "' has been deprecated and will be removed on " +
1375  removal_date + ". Please use '" + new_name + "' instead.";
1376 
1377  _old_to_new_name_and_dep.emplace(old_name, std::make_pair(new_name, deprecation_message));
1378  _new_to_old_names.emplace(new_name, old_name);
1379 }
1380 
1381 void
1382 InputParameters::renameCoupledVarInternal(const std::string & old_name,
1383  const std::string & new_name,
1384  const std::string & docstring,
1385  const std::string & removal_date)
1386 {
1387  auto coupled_vars_it = _coupled_vars.find(old_name);
1388  if (coupled_vars_it == _coupled_vars.end())
1389  mooseError("Requested to rename coupled variable '",
1390  old_name,
1391  "' but that coupled variable name doesn't exist in the parameters object.");
1392 
1393  _coupled_vars.insert(new_name);
1394  _coupled_vars.erase(coupled_vars_it);
1395 
1396  renameParamInternal(old_name, new_name, docstring, removal_date);
1397 }
1398 
1399 void
1400 InputParameters::renameParam(const std::string & old_name,
1401  const std::string & new_name,
1402  const std::string & new_docstring)
1403 {
1404  renameParamInternal(old_name, new_name, new_docstring, "");
1405 }
1406 
1407 void
1408 InputParameters::renameCoupledVar(const std::string & old_name,
1409  const std::string & new_name,
1410  const std::string & new_docstring)
1411 {
1412  renameCoupledVarInternal(old_name, new_name, new_docstring, "");
1413 }
1414 
1415 void
1416 InputParameters::deprecateParam(const std::string & old_name,
1417  const std::string & new_name,
1418  const std::string & removal_date)
1419 {
1420  renameParamInternal(old_name, new_name, "", removal_date);
1421 }
1422 
1423 void
1424 InputParameters::deprecateCoupledVar(const std::string & old_name,
1425  const std::string & new_name,
1426  const std::string & removal_date)
1427 {
1428  renameCoupledVarInternal(old_name, new_name, "", removal_date);
1429 }
1430 
1431 std::string
1432 InputParameters::checkForRename(const std::string & name) const
1433 {
1434  if (auto it = _old_to_new_name_and_dep.find(name); it != _old_to_new_name_and_dep.end())
1435  return it->second.first;
1436  else
1437  return name;
1438 }
1439 
1440 std::vector<std::string>
1441 InputParameters::paramAliases(const std::string & param_name) const
1442 {
1443  mooseAssert(_values.find(param_name) != _values.end(),
1444  "The parameter we are searching for aliases for should exist in our parameter map");
1445  std::vector<std::string> aliases = {param_name};
1446 
1447  for (const auto & pr : as_range(_new_to_old_names.equal_range(param_name)))
1448  aliases.push_back(pr.second);
1449 
1450  return aliases;
1451 }
1452 
1453 void
1454 InputParameters::callMooseErrorHelper(const MooseObject & object, const std::string & error)
1455 {
1456  object.mooseError(error);
1457 }
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::vector< std::string > syntax
The syntax for the parameter (i.e., ["-t", "--timing"])
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
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.
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:642
bool hasCoupledValue(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
void isValid(MooseObject *obj)
Definition: TheWarehouse.C:287
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 ...
Definition: MooseUtils.h:779
RelationshipManagerType
Main types of Relationship Managers.
Definition: MooseTypes.h:876
InputParameters & operator=(const InputParameters &rhs)
std::map< std::string, std::pair< std::string, std::string > > getAutoBuildVectors() const
Returns the auto build vectors for all parameters.
std::set< std::string > getParametersList() const
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.
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::vector< std::string > & getCommandLineSyntax(const std::string &name) const
CommandLineMetadata::ArgumentType getCommandLineArgumentType(const std::string &name) const
bool isControllable(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is controllable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
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::string _block_location
original location of input block (i.e. filename,linenum) - used for nice error messages.
std::set< ExecFlagType > _controllable_flags
Controllable execute flag restriction.
std::unordered_map< std::string, std::string > _new_to_deprecated_coupled_vars
A map from deprecated coupled variable names to the new blessed name.
std::string _block_fullpath
full HIT path of the block from the input file - used for nice error messages.
const std::vector< std::string > & getBuildableTypes() const
Returns the list of buildable types as a std::vector<std::string>
void setDeprecatedVarDocString(const std::string &new_name, const std::string &doc_string)
Private method for setting deprecated coupled variable documentation strings.
InputParameters & operator+=(const InputParameters &rhs)
ArgumentType argument_type
The type of argument.
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...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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.
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 ...
void registerBuildableTypes(const std::string &names)
This method is here to indicate which Moose types a particular Action may build.
bool attemptPrintDeprecated(const std::string &name)
Prints the deprecated parameter message, assuming we have the right flags set.
bool isPrivate(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is private or not.
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 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)
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...
const std::string & getDescription(const std::string &name) const
Get the documentation string for a parameter.
Structure for storing information about a command line parameter.
bool isParamSetByAddParam(const std::string &name) const
Returns whether or not the parameter was set due to addParam.
bool _show_deprecated_message
Flag for disabling deprecated parameters message, this is used by applyParameters to avoid dumping me...
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)
void deprecateParam(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
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::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
The type for the callback to set RelationshipManager parameters.
Definition: MooseTypes.h:902
bool hasDefaultCoupledValue(const std::string &coupling_name) const
Return whether or not the requested parameter has a default coupled value.
bool areAllRequiredParamsValid() const
This method returns true if all of the parameters in this object are valid (i.e.
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
const std::string & inputLocation(const std::string &param) const
Get/set a string representing the location in the input text the parameter originated from (i...
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.
Definition: MooseUtils.C:214
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)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
std::string appendFunctorDescription(const std::string &doc_string) const
Appends description of what a functor is to a doc string.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:313
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...
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false)
Apply values from a single parameter in common, to a single parameter stored in this object...
void applyParameters(const InputParameters &common, std::vector< std::string > exclude=std::vector< std::string >())
Method for applying common parameters.
static void callMooseErrorHelper(const MooseObject &object, const std::string &error)
std::set< std::string > reservedValues(const std::string &name) const
Get a set of reserved parameter values.
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, Args &&... args)
Definition: MooseError.h:236
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.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
Definition: InfixIterator.h:46
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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)
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.
std::string & blockFullpath()
Get/set a string representing the full HIT parameter path from the input file (e.g.
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 checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
bool isCommandLineParameter(const std::string &name) const
bool paramSetByUser(const std::string &name) const
Deprecated method.
bool isParamRequired(const std::string &name) const
Returns a boolean indicating whether the specified parameter is required or not.
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 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 option 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.
virtual void clear() override
bool hasDefault(const std::string &param_name) const
Return whether a parameter has a default.
std::map< std::string, Metadata > _params
The actual parameter data.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual void set_attributes(const std::string &name, bool inserted_only) override
Override from libMesh to set user-defined attributes on our parameter.
std::string getClassDescription() const
Returns the class description.
std::string errorPrefix(const std::string &param) const
generate error message prefix with parameter name and location (if available)
InputParameters emptyInputParameters()
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.
std::vector< ElemQuality > valid(const ElemType t)
std::vector< std::string > getVecMooseType(const std::string &name) const
std::optional< CommandLineMetadata > _cl_data
The data pertaining to a command line parameter (empty if not a command line param) ...
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 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
std::string & blockLocation()
Get/set a string representing the location (i.e.
const std::string & paramFullpath(const std::string &param) const
Get/set a string representing the full HIT parameter path from the input file (e.g.
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.