www.mooseframework.org
InputParameters.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef INPUTPARAMETERS_H
16 #define INPUTPARAMETERS_H
17 
18 // MOOSE includes
19 #include "MooseError.h"
20 #include "MooseTypes.h"
21 #include "MooseUtils.h"
22 
23 #include "libmesh/parameters.h"
24 #include "libmesh/parsed_function.h"
25 
26 #ifdef LIBMESH_HAVE_FPARSER
27 #include "libmesh/fparser.hh"
28 #else
29 template <typename T>
31 {
32 };
33 #endif
34 
35 // Forward declarations
36 class Action;
37 class InputParameters;
38 class MooseApp;
39 class MooseEnum;
40 class MooseObject;
41 class MultiMooseEnum;
42 class Problem;
43 
48 template <class T>
50 
55 class InputParameters : public Parameters
56 {
57 public:
58  InputParameters(const InputParameters & rhs);
59  InputParameters(const Parameters & rhs);
60 
61  virtual ~InputParameters() = default;
62 
63  virtual void clear() override;
64 
69  void addClassDescription(const std::string & doc_string);
70 
74  std::string getClassDescription() const;
75 
79  virtual void set_attributes(const std::string & name, bool inserted_only) override;
80 
96  template <typename T>
97  T & set(const std::string & name, bool quiet_mode = false);
98 
103  template <typename T, typename UP_T>
104  void rangeCheck(const std::string & full_name,
105  const std::string & short_name,
106  InputParameters::Parameter<T> * param,
107  std::ostream & oss = Moose::out);
108  template <typename T, typename UP_T>
109  void rangeCheck(const std::string & full_name,
110  const std::string & short_name,
111  InputParameters::Parameter<std::vector<T>> * param,
112  std::ostream & oss = Moose::out);
113 
118  template <typename T>
119  T getCheckedPointerParam(const std::string & name, const std::string & error_string = "") const;
120 
126  template <typename T>
127  void addRequiredParam(const std::string & name, const std::string & doc_string);
128 
133  template <typename T>
134  void
135  addRequiredParam(const std::string & name, const T & moose_enum, const std::string & doc_string);
136 
143  template <typename T, typename S>
144  void addParam(const std::string & name, const S & value, const std::string & doc_string);
145  template <typename T>
146  void addParam(const std::string & name, const std::string & doc_string);
147 
152  template <typename T>
153  void addRequiredRangeCheckedParam(const std::string & name,
154  const std::string & parsed_function,
155  const std::string & doc_string);
156  template <typename T>
157  void addRangeCheckedParam(const std::string & name,
158  const T & value,
159  const std::string & parsed_function,
160  const std::string & doc_string);
161  template <typename T>
162  void addRangeCheckedParam(const std::string & name,
163  const std::string & parsed_function,
164  const std::string & doc_string);
165 
171  template <typename T>
172  void addRequiredCustomTypeParam(const std::string & name,
173  const std::string & custom_type,
174  const std::string & doc_string);
175  template <typename T>
176  void addCustomTypeParam(const std::string & name,
177  const T & value,
178  const std::string & custom_type,
179  const std::string & doc_string);
180  template <typename T>
181  void addCustomTypeParam(const std::string & name,
182  const std::string & custom_type,
183  const std::string & doc_string);
184 
191  template <typename T>
192  void addPrivateParam(const std::string & name, const T & value);
193  template <typename T>
194  void addPrivateParam(const std::string & name);
195 
205  template <typename T>
206  void addRequiredCommandLineParam(const std::string & name,
207  const std::string & syntax,
208  const std::string & doc_string);
209  template <typename T>
210  void addCommandLineParam(const std::string & name,
211  const std::string & syntax,
212  const std::string & doc_string);
213  template <typename T>
214  void addCommandLineParam(const std::string & name,
215  const std::string & syntax,
216  const T & value,
217  const std::string & doc_string);
218 
229  template <typename T>
230  void addRequiredDeprecatedParam(const std::string & name,
231  const std::string & doc_string,
232  const std::string & deprecation_message);
233 
241  template <typename T>
242  void addDeprecatedParam(const std::string & name,
243  const T & value,
244  const std::string & doc_string,
245  const std::string & deprecation_message);
246 
247  template <typename T>
248  void addDeprecatedParam(const std::string & name,
249  const std::string & doc_string,
250  const std::string & deprecation_message);
251 
261  template <typename T>
262  void checkConsistentType(const std::string & name) const;
263 
267  std::vector<std::string> getSyntax(const std::string & name);
268 
272  const std::string & getDescription(const std::string & name);
273 
279  void addParamNamesToGroup(const std::string & space_delim_names, const std::string group_name);
280 
285  std::string getGroupName(const std::string & param_name) const;
286 
293  template <typename T>
294  void suppressParameter(const std::string & name);
295 
300  template <typename T>
301  void makeParamRequired(const std::string & name);
302 
308  void addCoupledVar(const std::string & name, const std::string & doc_string);
309 
318  void addCoupledVar(const std::string & name, const Real value, const std::string & doc_string);
319 
321 
338  void addCoupledVarWithAutoBuild(const std::string & name,
339  const std::string & base_name,
340  const std::string & num_name,
341  const std::string & doc_string);
342  void addRequiredCoupledVarWithAutoBuild(const std::string & name,
343  const std::string & base_name,
344  const std::string & num_name,
345  const std::string & doc_string);
347 
353  std::string getMooseType(const std::string & name) const;
354  std::vector<std::string> getVecMooseType(const std::string & name) const;
355 
365  void addRequiredCoupledVar(const std::string & name, const std::string & doc_string);
366 
370  std::string getDocString(const std::string & name) const;
371 
379  void setDocString(const std::string & name, const std::string & doc);
380 
384  bool isParamRequired(const std::string & name) const;
385 
391  bool isParamValid(const std::string & name) const;
392 
398  bool isParamSetByAddParam(const std::string & name) const;
399 
404  bool areAllRequiredParamsValid() const;
405 
409  std::string type(const std::string & name);
410 
414  bool isPrivate(const std::string & name) const;
415 
419  void declareControllable(const std::string & name);
420 
424  void markControlled(const std::string & name);
425 
429  bool isControllable(const std::string & name);
430 
436  void registerBase(const std::string & value);
437 
447  void registerBuildableTypes(const std::string & names);
448 
452  const std::vector<std::string> & getBuildableTypes() const;
453 
458  void collapseSyntaxNesting(bool collapse);
459  bool collapseSyntaxNesting() const;
460 
465  void mooseObjectSyntaxVisibility(bool visibility);
466  bool mooseObjectSyntaxVisibility() const;
467 
471  using Parameters::operator=;
472  using Parameters::operator+=;
473  InputParameters & operator=(const InputParameters & rhs);
474  InputParameters & operator+=(const InputParameters & rhs);
475 
482  void checkParams(const std::string & parsing_syntax);
483 
488  inline std::set<std::string>::const_iterator coupledVarsBegin() const
489  {
490  return _coupled_vars.begin();
491  }
492  inline std::set<std::string>::const_iterator coupledVarsEnd() const
493  {
494  return _coupled_vars.end();
495  }
496 
500  const std::set<std::string> & getCoupledVariableParamNames() const { return _coupled_vars; }
501 
507  bool hasCoupledValue(const std::string & coupling_name) const;
508 
514  bool hasDefaultCoupledValue(const std::string & coupling_name) const;
515 
521  Real defaultCoupledValue(const std::string & coupling_name) const;
522 
529  void defaultCoupledValue(const std::string & coupling_name, Real value);
530 
534  const std::map<std::string, std::pair<std::string, std::string>> & getAutoBuildVectors() const;
535 
542  const PostprocessorValue & getDefaultPostprocessorValue(const std::string & name,
543  bool suppress_error = false) const;
544 
550  void setDefaultPostprocessorValue(const std::string & name, const PostprocessorValue & value);
551 
557  bool hasDefaultPostprocessorValue(const std::string & name) const;
558 
576  void applyParameters(const InputParameters & common,
577  std::vector<std::string> exclude = std::vector<std::string>());
578 
596  void applySpecificParameters(const InputParameters & common,
597  const std::vector<std::string> & include);
598 
610  void applyParameter(const InputParameters & common, const std::string & common_name);
611 
622  void applyCoupledVar(const InputParameters & common, const std::string & var_name);
623 
627  bool paramSetByUser(const std::string & name) const;
628 
633  bool isParamSetByUser(const std::string & name) const;
634 
636  /*
637  * These methods are here to retrieve parameters for scalar and vector types respectively. We will
638  * throw errors
639  * when returning most scalar types, but will allow retrieving empty vectors.
640  */
641  template <typename T>
642  static const T &
643  getParamHelper(const std::string & name, const InputParameters & pars, const T * the_type);
644 
645  template <typename T>
646  static const std::vector<T> & getParamHelper(const std::string & name,
647  const InputParameters & pars,
648  const std::vector<T> * the_type);
650 
654  const std::set<std::string> & getControllableParameters() const { return _controllable_params; }
655 
660  void setReservedValues(const std::string & name, const std::set<std::string> & reserved);
661 
666  std::set<std::string> reservedValues(const std::string & name) const;
667 
668 private:
669  // Private constructor so that InputParameters can only be created in certain places.
670  InputParameters();
671 
681  void allowCopy(bool status) { _allow_copy = status; }
682 
684  void checkParamName(const std::string & name) const;
685 
687  template <typename T, typename S>
688  void setParamHelper(const std::string & name, T & l_value, const S & r_value);
689 
691  std::map<std::string, std::string> _doc_string;
692 
694  std::map<std::string, std::string> _custom_type;
695 
697  std::map<std::string, std::vector<std::string>> _syntax;
698 
700  std::map<std::string, std::string> _group;
701 
703  std::map<std::string, std::string> _range_functions;
704 
706  std::map<std::string, std::pair<std::string, std::string>> _auto_build_vectors;
707 
710  std::vector<std::string> _buildable_types;
711 
715 
718 
720  std::set<std::string> _required_params;
721 
727  std::set<std::string> _valid_params;
728 
730  std::set<std::string> _private_params;
731 
733  std::set<std::string> _coupled_vars;
734 
736  std::map<std::string, std::string> _deprecated_params;
737 
739  std::map<std::string, Real> _default_coupled_value;
740 
742  std::map<std::string, PostprocessorValue> _default_postprocessor_value;
743 
745  std::set<std::string> _set_by_add_param;
746 
748  std::set<std::string> _controllable_params;
749 
751  std::map<std::string, std::set<std::string>> _reserved_values;
752 
755 
758 
759  // These are the only objects allowed to _create_ InputParameters
766 };
767 
768 // Template and inline function implementations
769 template <typename T>
770 T &
771 InputParameters::set(const std::string & name, bool quiet_mode)
772 {
773  checkParamName(name);
774  checkConsistentType<T>(name);
775 
776  if (!this->have_parameter<T>(name))
777  _values[name] = new Parameter<T>;
778 
779  set_attributes(name, false);
780 
781  if (quiet_mode)
782  _set_by_add_param.insert(name);
783 
784  return cast_ptr<Parameter<T> *>(_values[name])->set();
785 }
786 
787 template <typename T, typename UP_T>
788 void
789 InputParameters::rangeCheck(const std::string & full_name,
790  const std::string & short_name,
791  InputParameters::Parameter<std::vector<T>> * param,
792  std::ostream & oss)
793 {
794  mooseAssert(param, "Parameter is NULL");
795 
796  if (_range_functions.count(short_name) == 0 || !isParamValid(short_name))
797  return;
798 
811  std::vector<std::string> vars;
812  if (fp.ParseAndDeduceVariables(_range_functions[short_name], vars) != -1) // -1 for success
813  {
814  oss << "Error parsing expression: " << _range_functions[short_name] << '\n';
815  return;
816  }
817 
818  // Fparser parameter buffer
819  std::vector<UP_T> parbuf(vars.size());
820 
821  // parameter vector
822  const std::vector<T> & value = param->set();
823 
824  // iterate over all vector values (maybe ;)
825  bool need_to_iterate = false;
826  unsigned int i = 0;
827  do
828  {
829  // set parameters
830  for (unsigned int j = 0; j < vars.size(); j++)
831  {
832  if (vars[j] == short_name)
833  {
834  if (value.size() == 0)
835  {
836  oss << "Range checking empty vector: " << _range_functions[short_name] << '\n';
837  return;
838  }
839 
840  parbuf[j] = value[i];
841  need_to_iterate = true;
842  }
843  else if (vars[j] == short_name + "_size")
844  parbuf[j] = value.size();
845  else
846  {
847  if (vars[j].substr(0, short_name.size() + 1) != short_name + "_")
848  {
849  oss << "Error parsing expression: " << _range_functions[short_name] << '\n';
850  return;
851  }
852  std::istringstream iss(vars[j]);
853  iss.seekg(short_name.size() + 1);
854 
855  size_t index;
856  if (iss >> index && iss.eof())
857  {
858  if (index >= value.size())
859  {
860  oss << "Error parsing expression: " << _range_functions[short_name]
861  << "\nOut of range variable " << vars[j] << '\n';
862  return;
863  }
864  parbuf[j] = value[index];
865  }
866  else
867  {
868  oss << "Error parsing expression: " << _range_functions[short_name]
869  << "\nInvalid variable " << vars[j] << '\n';
870  return;
871  }
872  }
873  }
874 
875  // ensure range-checked input file parameter comparison functions
876  // do absolute floating point comparisons instead of using a default epsilon.
877  auto tmp_eps = fp.epsilon();
878  fp.setEpsilon(0);
879  UP_T result = fp.Eval(&parbuf[0]);
880  fp.setEpsilon(tmp_eps);
881 
882  // test function using the parameters determined above
883  if (fp.EvalError())
884  {
885  oss << "Error evaluating expression: " << _range_functions[short_name] << '\n';
886  return;
887  }
888 
889  if (!result)
890  {
891  oss << "Range check failed for parameter " << full_name
892  << "\n\tExpression: " << _range_functions[short_name] << "\n";
893  if (need_to_iterate)
894  oss << "\t Component: " << i << '\n';
895  }
896 
897  } while (need_to_iterate && ++i < value.size());
898 }
899 
900 template <typename T, typename UP_T>
901 void
902 InputParameters::rangeCheck(const std::string & full_name,
903  const std::string & short_name,
904  InputParameters::Parameter<T> * param,
905  std::ostream & oss)
906 {
907  mooseAssert(param, "Parameter is NULL");
908 
909  if (_range_functions.find(short_name) == _range_functions.end() || !isParamValid(short_name))
910  return;
911 
912  // Parse the expression
914  if (fp.Parse(_range_functions[short_name], short_name) != -1) // -1 for success
915  {
916  oss << "Error parsing expression: " << _range_functions[short_name] << '\n';
917  return;
918  }
919 
920  // ensure range-checked input file parameter comparison functions
921  // do absolute floating point comparisons instead of using a default epsilon.
922  auto tmp_eps = fp.epsilon();
923  fp.setEpsilon(0);
924  // We require a non-const value for the implicit upscaling of the parameter type
925  std::vector<UP_T> value(1, param->set());
926  UP_T result = fp.Eval(&value[0]);
927  fp.setEpsilon(tmp_eps);
928 
929  if (fp.EvalError())
930  {
931  oss << "Error evaluating expression: " << _range_functions[short_name]
932  << "\nPerhaps you used the wrong variable name?\n";
933  return;
934  }
935 
936  if (!result)
937  oss << "Range check failed for parameter " << full_name
938  << "\n\tExpression: " << _range_functions[short_name] << "\n\tValue: " << value[0] << '\n';
939 }
940 
941 template <typename T>
942 T
944  const std::string & error_string) const
945 {
946  T param = this->get<T>(name);
947 
948  // Note: You will receive a compile error on this line if you attempt to pass a non-pointer
949  // template type to this method
950  if (param == NULL)
951  mooseError("Parameter ", name, " is NULL.\n", error_string);
952  return this->get<T>(name);
953 }
954 
955 template <typename T>
956 void
957 InputParameters::addRequiredParam(const std::string & name, const std::string & doc_string)
958 {
959  checkParamName(name);
960  checkConsistentType<T>(name);
961 
962  InputParameters::insert<T>(name);
963  _required_params.insert(name);
964  _doc_string[name] = doc_string;
965 }
966 
967 template <typename T>
968 void
969 InputParameters::addRequiredParam(const std::string & /*name*/,
970  const T & /*value*/,
971  const std::string & /*doc_string*/)
972 {
973  mooseError("You cannot call addRequiredParam and supply a default value for this type, please "
974  "use addParam instead");
975 }
976 
977 template <typename T, typename S>
978 void
979 InputParameters::addParam(const std::string & name, const S & value, const std::string & doc_string)
980 {
981  checkParamName(name);
982  checkConsistentType<T>(name);
983 
984  T & l_value = InputParameters::set<T>(name);
985  _doc_string[name] = doc_string;
986 
987  // Set the parameter now
988  setParamHelper(name, l_value, value);
989 
990  /* Indicate the default value, as set via addParam, is being used. The parameter is removed from
991  the list whenever
992  it changes, see set_attributes */
993  _set_by_add_param.insert(name);
994 }
995 
996 template <typename T>
997 void
998 InputParameters::addParam(const std::string & name, const std::string & doc_string)
999 {
1000  checkParamName(name);
1001  checkConsistentType<T>(name);
1002 
1003  InputParameters::insert<T>(name);
1004  _doc_string[name] = doc_string;
1005 }
1006 
1007 template <typename T, typename S>
1008 void
1009 InputParameters::setParamHelper(const std::string & /*name*/, T & l_value, const S & r_value)
1010 {
1011  l_value = r_value;
1012 }
1013 
1014 template <typename T>
1015 void
1017  const std::string & parsed_function,
1018  const std::string & doc_string)
1019 {
1020  addRequiredParam<T>(name, doc_string);
1021  _range_functions[name] = parsed_function;
1022 }
1023 
1024 template <typename T>
1025 void
1026 InputParameters::addRangeCheckedParam(const std::string & name,
1027  const T & value,
1028  const std::string & parsed_function,
1029  const std::string & doc_string)
1030 {
1031  addParam<T>(name, value, doc_string);
1032  _range_functions[name] = parsed_function;
1033 }
1034 
1035 template <typename T>
1036 void
1037 InputParameters::addRangeCheckedParam(const std::string & name,
1038  const std::string & parsed_function,
1039  const std::string & doc_string)
1040 {
1041  addParam<T>(name, doc_string);
1042  _range_functions[name] = parsed_function;
1043 }
1044 
1045 template <typename T>
1046 void
1048  const std::string & custom_type,
1049  const std::string & doc_string)
1050 {
1051  addRequiredParam<T>(name, doc_string);
1052  _custom_type[name] = custom_type;
1053 }
1054 
1055 template <typename T>
1056 void
1057 InputParameters::addCustomTypeParam(const std::string & name,
1058  const T & value,
1059  const std::string & custom_type,
1060  const std::string & doc_string)
1061 {
1062  addParam<T>(name, value, doc_string);
1063  _custom_type[name] = custom_type;
1064 }
1065 
1066 template <typename T>
1067 void
1068 InputParameters::addCustomTypeParam(const std::string & name,
1069  const std::string & custom_type,
1070  const std::string & doc_string)
1071 {
1072  addParam<T>(name, doc_string);
1073  _custom_type[name] = custom_type;
1074 }
1075 
1076 template <typename T>
1077 void
1078 InputParameters::addPrivateParam(const std::string & name)
1079 {
1080  checkParamName(name);
1081  checkConsistentType<T>(name);
1082 
1083  InputParameters::insert<T>(name);
1084  _private_params.insert(name);
1085 }
1086 
1087 template <typename T>
1088 void
1089 InputParameters::addPrivateParam(const std::string & name, const T & value)
1090 {
1091  checkParamName(name);
1092  checkConsistentType<T>(name);
1093 
1094  InputParameters::set<T>(name) = value;
1095  _private_params.insert(name);
1096  _set_by_add_param.insert(name);
1097 }
1098 
1099 template <typename T>
1100 void
1102  const std::string & syntax,
1103  const std::string & doc_string)
1104 {
1105  addRequiredParam<T>(name, doc_string);
1106  MooseUtils::tokenize(syntax, _syntax[name], 1, " \t\n\v\f\r");
1107 }
1108 
1109 template <typename T>
1110 void
1111 InputParameters::addCommandLineParam(const std::string & name,
1112  const std::string & syntax,
1113  const std::string & doc_string)
1114 {
1115  addParam<T>(name, doc_string);
1116  MooseUtils::tokenize(syntax, _syntax[name], 1, " \t\n\v\f\r");
1117 }
1118 
1119 template <typename T>
1120 void
1121 InputParameters::addCommandLineParam(const std::string & name,
1122  const std::string & syntax,
1123  const T & value,
1124  const std::string & doc_string)
1125 {
1126  addParam<T>(name, value, doc_string);
1127  MooseUtils::tokenize(syntax, _syntax[name], 1, " \t\n\v\f\r");
1128 }
1129 
1130 template <typename T>
1131 void
1132 InputParameters::checkConsistentType(const std::string & name) const
1133 {
1134  // Do we have a paremeter with the same name but a different type?
1135  InputParameters::const_iterator it = _values.find(name);
1136  if (it != _values.end() && dynamic_cast<const Parameter<T> *>(it->second) == NULL)
1137  mooseError("Attempting to set parameter \"",
1138  name,
1139  "\" with type (",
1140  demangle(typeid(T).name()),
1141  ")\nbut the parameter already exists as type (",
1142  it->second->type(),
1143  ")");
1144 }
1145 
1146 template <typename T>
1147 void
1148 InputParameters::suppressParameter(const std::string & name)
1149 {
1150  if (!this->have_parameter<T>(name))
1151  mooseError("Unable to suppress nonexistent parameter: ", name);
1152 
1153  _required_params.erase(name);
1154  _private_params.insert(name);
1155 }
1156 
1157 template <typename T>
1158 void
1160  const std::string & doc_string,
1161  const std::string & deprecation_message)
1162 {
1163  _show_deprecated_message = false;
1164  addRequiredParam<T>(name, doc_string);
1165 
1166  _deprecated_params.insert(std::make_pair(name, deprecation_message));
1167  _show_deprecated_message = true;
1168 }
1169 
1170 template <typename T>
1171 void
1172 InputParameters::addDeprecatedParam(const std::string & name,
1173  const T & value,
1174  const std::string & doc_string,
1175  const std::string & deprecation_message)
1176 {
1177  _show_deprecated_message = false;
1178  addParam<T>(name, value, doc_string);
1179 
1180  _deprecated_params.insert(std::make_pair(name, deprecation_message));
1181  _show_deprecated_message = true;
1182 }
1183 
1184 template <typename T>
1185 void
1186 InputParameters::addDeprecatedParam(const std::string & name,
1187  const std::string & doc_string,
1188  const std::string & deprecation_message)
1189 {
1190  _show_deprecated_message = false;
1191  addParam<T>(name, doc_string);
1192 
1193  _deprecated_params.insert(std::make_pair(name, deprecation_message));
1194  _show_deprecated_message = true;
1195 }
1196 
1197 // Forward declare MooseEnum specializations for add*Param
1198 template <>
1199 void InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
1200  const MooseEnum & moose_enum,
1201  const std::string & doc_string);
1202 
1203 template <>
1204 void InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1205  const MultiMooseEnum & moose_enum,
1206  const std::string & doc_string);
1207 
1208 template <>
1209 void InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1210  const std::string & name,
1211  const std::vector<MooseEnum> & moose_enums,
1212  const std::string & doc_string);
1213 
1214 template <>
1215 void InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1216  const std::string & /*doc_string*/);
1217 
1218 template <>
1219 void InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1220  const std::string & /*doc_string*/);
1221 
1222 template <>
1223 void InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1224  const std::string & /*doc_string*/);
1225 
1226 template <>
1227 void InputParameters::addDeprecatedParam<MooseEnum>(const std::string & name,
1228  const std::string & doc_string,
1229  const std::string & deprecation_message);
1230 
1231 template <>
1232 void InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & name,
1233  const std::string & doc_string,
1234  const std::string & deprecation_message);
1235 
1236 template <>
1237 void InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1238  const std::string & name,
1239  const std::string & doc_string,
1240  const std::string & deprecation_message);
1241 
1242 // Forward declare specializations for setParamHelper
1243 template <>
1244 void InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & name,
1245  PostprocessorName & l_value,
1246  const Real & r_value);
1247 
1248 template <>
1249 void InputParameters::setParamHelper<PostprocessorName, int>(const std::string & name,
1250  PostprocessorName & l_value,
1251  const int & r_value);
1252 
1253 template <>
1254 void InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1255  FunctionName & l_value,
1256  const Real & r_value);
1257 
1258 template <>
1259 void InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1260  FunctionName & l_value,
1261  const int & r_value);
1262 
1263 template <>
1264 void InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1265  MaterialPropertyName & l_value,
1266  const Real & r_value);
1267 
1268 template <>
1269 void InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1270  MaterialPropertyName & l_value,
1271  const int & r_value);
1272 
1273 template <typename T>
1274 const T &
1275 InputParameters::getParamHelper(const std::string & name, const InputParameters & pars, const T *)
1276 {
1277  if (!pars.isParamValid(name))
1278  mooseError("The parameter \"", name, "\" is being retrieved before being set.\n");
1279  return pars.get<T>(name);
1280 }
1281 
1282 // Declare specializations so we don't fall back on the generic
1283 // implementation, but the definition will be in InputParameters.C so
1284 // we won't need to bring in *MooseEnum header files here.
1285 template <>
1286 const MooseEnum & InputParameters::getParamHelper<MooseEnum>(const std::string & name,
1287  const InputParameters & pars,
1288  const MooseEnum *);
1289 
1290 template <>
1291 const MultiMooseEnum & InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name,
1292  const InputParameters & pars,
1293  const MultiMooseEnum *);
1294 
1295 template <typename T>
1296 const std::vector<T> &
1297 InputParameters::getParamHelper(const std::string & name,
1298  const InputParameters & pars,
1299  const std::vector<T> *)
1300 {
1301  return pars.get<std::vector<T>>(name);
1302 }
1303 
1305 
1306 #endif /* INPUTPARAMETERS_H */
const std::set< std::string > & getCoupledVariableParamNames() const
Return the coupled variable parameter names.
static const T & getParamHelper(const std::string &name, const InputParameters &pars, const T *the_type)
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
Storage container for all InputParamter objects.
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:350
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
std::map< std::string, std::string > _custom_type
The custom type that will be printed in the YAML dump for a parameter if supplied.
std::set< std::string >::const_iterator coupledVarsEnd() const
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
std::map< std::string, std::string > _deprecated_params
The list of deprecated params.
std::map< std::string, std::string > _doc_string
The documentation strings for each parameter.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void addCustomTypeParam(const std::string &name, const T &value, const std::string &custom_type, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
std::map< std::string, std::string > _range_functions
The map of functions used for range checked parameters.
Class that hold the whole problem being solved.
Definition: Problem.h:29
Base class for MOOSE-based applications.
Definition: MooseApp.h:58
std::set< std::string > _required_params
The set of parameters that are required (i.e. will cause an abort if not supplied) ...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::map< std::string, std::string > _group
The names of the parameters organized into groups.
std::set< std::string > _private_params
The set of parameters that will NOT appear in the the dump of the parser tree.
void addRequiredCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
Add parameters for retrieval from the command line.
Base class for actions.
Definition: Action.h:39
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
InputParameters emptyInputParameters()
std::map< std::string, Real > _default_coupled_value
The default value for optionally coupled variables.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
InputParameters validParams()
This is the templated validParams() function that every MooseObject-derived class is required to spec...
void checkConsistentType(const std::string &name) const
This method checks to make sure that we aren&#39;t adding a parameter with the same name but a different ...
bool _show_deprecated_message
Flag for disabling deprecated parameters message, this is used by applyParameters to avoid dumping me...
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
bool _collapse_nesting
This parameter collapses one level of nesting in the syntax blocks.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:73
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
InputParameters validParams< MooseApp >()
Definition: MooseApp.C:60
std::map< std::string, std::pair< std::string, std::string > > _auto_build_vectors
The map of auto build vectors (base_, 5 -> "base_0 base_1 base_2 base_3 base_4")
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
void rangeCheck(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, std::ostream &oss=Moose::out)
Runs a range on the supplied parameter if it exists and throws an error if that check fails...
std::map< std::string, PostprocessorValue > _default_postprocessor_value
The default value for postprocessors.
void allowCopy(bool status)
Toggle the availability of the copy constructor.
std::set< std::string > _valid_params
The set of parameters either explicitly set or provided a default value when added Note: We do not st...
void addCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
MatType type
std::set< std::string > _coupled_vars
The coupled variables set.
std::set< std::string > _controllable_params
A list of parameters declared as controllable.
std::set< std::string >::const_iterator coupledVarsBegin() const
Methods returning iterators to the coupled variables names stored in this InputParameters object...
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
These methods add an option parameter and with a customer type to the InputParameters object...
InputParameters validParams< Problem >()
Definition: Problem.C:21
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.
std::map< std::string, std::set< std::string > > _reserved_values
The reserved option names for a parameter.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void setParamHelper(const std::string &name, T &l_value, const S &r_value)
This method is called when adding a Parameter with a default value, can be specialized for non-matchi...
void addRequiredDeprecatedParam(const std::string &name, const std::string &doc_string, const std::string &deprecation_message)
Add and mark a parameter for deprecation.
const std::set< std::string > & getControllableParameters() const
Return list of controllable parameters.
std::map< std::string, std::vector< std::string > > _syntax
Syntax for command-line parameters.
std::set< std::string > _set_by_add_param
If a parameters value was set by addParam, and not set again, it will appear in this list (see applyP...
InputParameters validParams< Action >()
Definition: Action.C:23