Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
3 : //*
4 : //* All rights reserved, see COPYRIGHT for full restrictions
5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 : //*
7 : //* Licensed under LGPL 2.1, please see LICENSE for details
8 : //* https://www.gnu.org/licenses/lgpl-2.1.html
9 :
10 : #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 : #include "MooseApp.h"
20 :
21 : #include "libmesh/utility.h"
22 : #include "libmesh/simple_range.h"
23 :
24 : #include "pcrecpp.h"
25 : #include "hit/parse.h"
26 :
27 : #include <cmath>
28 : #include <filesystem>
29 :
30 : InputParameters
31 169090240 : emptyInputParameters()
32 : {
33 169090240 : InputParameters params;
34 169090240 : return params;
35 : }
36 :
37 169090240 : InputParameters::InputParameters()
38 : : Parameters(),
39 169090240 : _collapse_nesting(false),
40 169090240 : _moose_object_syntax_visibility(true),
41 169090240 : _show_deprecated_message(true),
42 169090240 : _allow_copy(true),
43 169090240 : _hit_node(nullptr),
44 169090240 : _finalized(false)
45 : {
46 169090240 : }
47 :
48 8728375 : InputParameters::InputParameters(const InputParameters & rhs)
49 8728375 : : Parameters(), _show_deprecated_message(true), _allow_copy(true)
50 : {
51 8728375 : *this = rhs;
52 8728371 : }
53 :
54 0 : InputParameters::InputParameters(const Parameters & rhs)
55 0 : : _show_deprecated_message(true), _allow_copy(true)
56 : {
57 0 : _params.clear();
58 0 : Parameters::operator=(rhs);
59 0 : _collapse_nesting = false;
60 0 : _moose_object_syntax_visibility = true;
61 0 : }
62 :
63 : void
64 0 : InputParameters::clear()
65 : {
66 0 : Parameters::clear();
67 0 : _params.clear();
68 0 : _coupled_vars.clear();
69 0 : _new_to_deprecated_coupled_vars.clear();
70 0 : _collapse_nesting = false;
71 0 : _moose_object_syntax_visibility = true;
72 0 : _show_deprecated_message = true;
73 0 : _allow_copy = true;
74 0 : _old_to_new_name_and_dep.clear();
75 0 : _new_to_old_names.clear();
76 0 : _hit_node = nullptr;
77 0 : _finalized = false;
78 0 : }
79 :
80 : void
81 37995962 : InputParameters::addClassDescription(const std::string & doc_string)
82 : {
83 37995962 : _class_description = doc_string;
84 37995962 : }
85 :
86 : void
87 1216055430 : InputParameters::set_attributes(const std::string & name_in, bool inserted_only)
88 : {
89 1216055430 : const auto name = checkForRename(name_in);
90 :
91 1216055430 : if (!inserted_only)
92 : {
93 846405714 : auto & metadata = _params[name];
94 : /**
95 : * "._set_by_add_param" and ".deprecated_params" are not populated until after
96 : * the default value has already been set in libMesh (first callback to this
97 : * method). Therefore if a variable is in/not in one of these sets, you can
98 : * be assured it was put there outside of the "addParam*()" calls.
99 : */
100 846405714 : metadata._set_by_add_param = false;
101 :
102 : // valid_params don't make sense for MooseEnums
103 846405714 : if (!have_parameter<MooseEnum>(name) && !have_parameter<MultiMooseEnum>(name))
104 808476289 : metadata._valid = true;
105 : }
106 1216055430 : }
107 :
108 : std::optional<std::string>
109 2671115 : InputParameters::queryDeprecatedParamMessage(const std::string & name_in) const
110 : {
111 2671115 : const auto name = checkForRename(name_in);
112 2671115 : if (_show_deprecated_message)
113 : {
114 1710 : auto deprecation_message = [this](const auto & name, const auto & message) -> std::string
115 1710 : { return paramMessagePrefix(name) + message; };
116 :
117 2671115 : if (_params.count(name) && !libmesh_map_find(_params, name)._deprecation_message.empty())
118 2700 : return deprecation_message(name,
119 2700 : "The parameter '" + name + "' is deprecated.\n" +
120 2700 : libmesh_map_find(_params, name)._deprecation_message);
121 2669765 : else if (auto it = _old_to_new_name_and_dep.find(name_in);
122 2669765 : it != _old_to_new_name_and_dep.end() && !it->second.second.empty())
123 360 : return deprecation_message(name_in, it->second.second);
124 : }
125 2669405 : return {};
126 2671115 : }
127 :
128 : std::string
129 1129736 : InputParameters::getClassDescription() const
130 : {
131 1129736 : return _class_description;
132 : }
133 :
134 : InputParameters &
135 10274386 : InputParameters::operator=(const InputParameters & rhs)
136 : {
137 : // An error to help minimize the segmentation faults that occure when MooseObjects do not have the
138 : // correct constructor
139 10274386 : if (!rhs._allow_copy)
140 : {
141 : // If _allow_parameter_copy is set, these should be too (see
142 : // InputParameterWarehouse::addInputParameters)
143 4 : const std::string & name = rhs.getObjectName();
144 4 : const std::string & type = rhs.getObjectType(); // could be empty
145 4 : const std::string name_example = type.size() ? type : "the " + name + " object";
146 4 : const std::string type_example = type.size() ? type : "MyObject";
147 4 : ::mooseError(
148 : "Copying of the InputParameters object for ",
149 : name_example,
150 : " is not allowed.\n\nThe likely cause for this error ",
151 : "is having a constructor that does not use a const reference, all constructors\nfor "
152 : "MooseObject based classes should be as follows:\n\n",
153 : " ",
154 : type_example,
155 : "::",
156 : type_example,
157 : "(const InputParameters & parameters);");
158 0 : }
159 :
160 10274382 : Parameters::operator=(rhs);
161 :
162 10274382 : _params = rhs._params;
163 :
164 10274382 : _buildable_types = rhs._buildable_types;
165 10274382 : _buildable_rm_types = rhs._buildable_rm_types;
166 10274382 : _collapse_nesting = rhs._collapse_nesting;
167 10274382 : _moose_object_syntax_visibility = rhs._moose_object_syntax_visibility;
168 10274382 : _coupled_vars = rhs._coupled_vars;
169 10274382 : _new_to_deprecated_coupled_vars = rhs._new_to_deprecated_coupled_vars;
170 10274382 : _allow_copy = rhs._allow_copy;
171 10274382 : _old_to_new_name_and_dep = rhs._old_to_new_name_and_dep;
172 10274382 : _new_to_old_names = rhs._new_to_old_names;
173 10274382 : _hit_node = rhs._hit_node;
174 10274382 : _finalized = false;
175 :
176 10274382 : return *this;
177 : }
178 :
179 : InputParameters &
180 135112422 : InputParameters::operator+=(const InputParameters & rhs)
181 : {
182 135112422 : Parameters::operator+=(rhs);
183 :
184 : // TODO: this is not a proper merge - if a particular parameter exists in both this and rhs,
185 : // then we should actually smartly merge both metadata structs before storing in this.
186 470367036 : for (auto it = rhs._params.begin(); it != rhs._params.end(); ++it)
187 335254614 : _params[it->first] = it->second;
188 :
189 270224844 : _buildable_types.insert(
190 135112422 : _buildable_types.end(), rhs._buildable_types.begin(), rhs._buildable_types.end());
191 270224844 : _buildable_rm_types.insert(
192 135112422 : _buildable_rm_types.end(), rhs._buildable_rm_types.begin(), rhs._buildable_rm_types.end());
193 :
194 : // Collapse nesting and moose object syntax hiding are not modified with +=
195 135112422 : _coupled_vars.insert(rhs._coupled_vars.begin(), rhs._coupled_vars.end());
196 135112422 : _new_to_deprecated_coupled_vars.insert(rhs._new_to_deprecated_coupled_vars.begin(),
197 : rhs._new_to_deprecated_coupled_vars.end());
198 :
199 135112422 : _old_to_new_name_and_dep.insert(rhs._old_to_new_name_and_dep.begin(),
200 : rhs._old_to_new_name_and_dep.end());
201 135112422 : _new_to_old_names.insert(rhs._new_to_old_names.begin(), rhs._new_to_old_names.end());
202 135112422 : return *this;
203 : }
204 :
205 : void
206 6331696 : InputParameters::setDeprecatedVarDocString(const std::string & new_name,
207 : const std::string & doc_string)
208 : {
209 6331696 : auto coupled_vars_it = _new_to_deprecated_coupled_vars.find(new_name);
210 6331696 : if (coupled_vars_it != _new_to_deprecated_coupled_vars.end())
211 : {
212 0 : auto params_it = _params.find(coupled_vars_it->second);
213 0 : if (params_it == _params.end())
214 0 : mooseError("There must have been a mistake in the construction of the new to deprecated "
215 : "coupled vars map because the old name ",
216 0 : coupled_vars_it->second,
217 : " doesn't exist in the parameters data.");
218 :
219 0 : params_it->second._doc_string = doc_string;
220 : }
221 6331696 : }
222 :
223 : void
224 345764 : InputParameters::addCoupledVar(const std::string & name, Real value, const std::string & doc_string)
225 : {
226 345764 : addParam<std::vector<VariableName>>(name, doc_string);
227 345764 : _coupled_vars.insert(name);
228 345764 : auto & metadata = _params[name];
229 345764 : metadata._coupled_default.assign(1, value);
230 345764 : metadata._have_coupled_default = true;
231 :
232 : // Set the doc string for any associated deprecated coupled var
233 345764 : setDeprecatedVarDocString(name, doc_string);
234 345764 : }
235 :
236 : void
237 114974 : InputParameters::addCoupledVar(const std::string & name,
238 : const std::vector<Real> & value,
239 : const std::string & doc_string)
240 : {
241 : // std::vector<VariableName>(1, Moose::stringify(value)),
242 114974 : addParam<std::vector<VariableName>>(name, doc_string);
243 114974 : _coupled_vars.insert(name);
244 114974 : auto & metadata = _params[name];
245 114974 : metadata._coupled_default = value;
246 114974 : metadata._have_coupled_default = true;
247 :
248 : // Set the doc string for any associated deprecated coupled var
249 114974 : setDeprecatedVarDocString(name, doc_string);
250 114974 : }
251 :
252 : void
253 5870958 : InputParameters::addCoupledVar(const std::string & name, const std::string & doc_string)
254 : {
255 5870958 : addParam<std::vector<VariableName>>(name, doc_string);
256 5870958 : _coupled_vars.insert(name);
257 :
258 : // Set the doc string for any associated deprecated coupled var
259 5870958 : setDeprecatedVarDocString(name, doc_string);
260 5870958 : }
261 :
262 : void
263 0 : InputParameters::addDeprecatedCoupledVar(const std::string & old_name,
264 : const std::string & new_name,
265 : const std::string & removal_date /*=""*/)
266 : {
267 0 : mooseDeprecated("Please use 'deprecateCoupledVar'");
268 :
269 0 : _show_deprecated_message = false;
270 :
271 : // Set the doc string if we are adding the deprecated var after the new var has already been added
272 0 : auto params_it = _params.find(new_name);
273 0 : std::string doc_string;
274 0 : if (params_it != _params.end())
275 0 : doc_string = params_it->second._doc_string;
276 :
277 0 : addParam<std::vector<VariableName>>(old_name, doc_string);
278 0 : _coupled_vars.insert(old_name);
279 0 : _new_to_deprecated_coupled_vars.emplace(new_name, old_name);
280 :
281 : std::string deprecation_message =
282 0 : "The coupled variable parameter '" + old_name + "' has been deprecated";
283 0 : if (!removal_date.empty())
284 0 : deprecation_message += " and will be removed " + removal_date;
285 0 : deprecation_message += ". Please use the '" + new_name + "' coupled variable parameter instead.";
286 0 : _params[old_name]._deprecation_message = deprecation_message;
287 0 : _show_deprecated_message = true;
288 0 : }
289 :
290 : void
291 4 : InputParameters::addCoupledVarWithAutoBuild(const std::string & name,
292 : const std::string & base_name,
293 : const std::string & num_name,
294 : const std::string & doc_string)
295 : {
296 4 : addParam<std::vector<VariableName>>(name, doc_string);
297 4 : _coupled_vars.insert(name);
298 4 : _params[name]._autobuild_vecs = std::make_pair(base_name, num_name);
299 :
300 : // Additionally there are two more parameters that need to be added:
301 4 : addParam<std::string>(base_name, doc_string + " (base_name)");
302 4 : addParam<unsigned int>(num_name, doc_string + " (num_name)");
303 4 : }
304 :
305 : void
306 4 : InputParameters::addRequiredCoupledVarWithAutoBuild(const std::string & name,
307 : const std::string & base_name,
308 : const std::string & num_name,
309 : const std::string & doc_string)
310 : {
311 4 : addRequiredParam<std::vector<VariableName>>(name, doc_string);
312 :
313 4 : addCoupledVarWithAutoBuild(name, base_name, num_name, doc_string);
314 4 : }
315 :
316 : void
317 4557821 : InputParameters::addRequiredCoupledVar(const std::string & name, const std::string & doc_string)
318 : {
319 4557821 : addRequiredParam<std::vector<VariableName>>(name, doc_string);
320 4557821 : _coupled_vars.insert(name);
321 4557821 : }
322 :
323 : std::string
324 12179936 : InputParameters::getDocString(const std::string & name_in) const
325 : {
326 12179936 : const auto name = checkForRename(name_in);
327 :
328 12179936 : std::string doc_string;
329 12179936 : auto it = _params.find(name);
330 12179936 : if (it != _params.end())
331 1004028371 : for (const auto & ch : it->second._doc_string)
332 : {
333 991848435 : if (ch == '\n')
334 0 : doc_string += " ... ";
335 : else
336 991848435 : doc_string += ch;
337 : }
338 :
339 24359872 : return doc_string;
340 12179936 : }
341 :
342 : void
343 4557206 : InputParameters::setDocString(const std::string & name_in, const std::string & doc)
344 : {
345 4557206 : const auto name = checkForRename(name_in);
346 :
347 4557206 : auto it = _params.find(name);
348 4557206 : if (it == _params.end())
349 1 : mooseError("Unable to set the documentation string (using setDocString) for the \"",
350 : name,
351 : "\" parameter, the parameter does not exist.");
352 4557205 : it->second._doc_string = doc;
353 4557206 : }
354 :
355 : std::string
356 7138118 : InputParameters::getDocUnit(const std::string & name_in) const
357 : {
358 7138118 : const auto name = checkForRename(name_in);
359 14276236 : return _params.at(name)._doc_unit;
360 7138118 : }
361 :
362 : void
363 0 : InputParameters::setDocUnit(const std::string & name_in, const std::string & doc_unit)
364 : {
365 0 : const auto name = checkForRename(name_in);
366 0 : _params[name]._doc_unit = doc_unit;
367 0 : }
368 :
369 : bool
370 63866258 : InputParameters::isParamRequired(const std::string & name_in) const
371 : {
372 63866258 : const auto name = checkForRename(name_in);
373 127732516 : return _params.count(name) > 0 && _params.at(name)._required;
374 63866258 : }
375 :
376 : void
377 28822 : InputParameters::makeParamNotRequired(const std::string & name_in)
378 : {
379 28822 : const auto name = checkForRename(name_in);
380 :
381 28822 : if (_params.count(name))
382 28820 : _params[name]._required = false;
383 28822 : }
384 :
385 : bool
386 366652586 : InputParameters::isParamValid(const std::string & name_in) const
387 : {
388 366652586 : const auto name = checkForRename(name_in);
389 366652586 : if (have_parameter<MooseEnum>(name))
390 6651490 : return get<MooseEnum>(name).isValid();
391 360001096 : else if (have_parameter<std::vector<MooseEnum>>(name))
392 : {
393 12725 : for (auto it = get<std::vector<MooseEnum>>(name).begin();
394 26045 : it != get<std::vector<MooseEnum>>(name).end();
395 13320 : ++it)
396 13322 : if (!it->isValid())
397 2 : return false;
398 12723 : return true;
399 : }
400 359988371 : else if (have_parameter<MultiMooseEnum>(name))
401 1843494 : return get<MultiMooseEnum>(name).isValid();
402 358144877 : else if (have_parameter<std::vector<MultiMooseEnum>>(name))
403 : {
404 241 : for (auto it = get<std::vector<MultiMooseEnum>>(name).begin();
405 505 : it != get<std::vector<MultiMooseEnum>>(name).end();
406 264 : ++it)
407 439 : if (!it->isValid())
408 175 : return false;
409 66 : return true;
410 : }
411 358144636 : else if (have_parameter<ExecFlagEnum>(name))
412 6847845 : return get<ExecFlagEnum>(name).isValid();
413 : else
414 351296791 : return _params.count(name) > 0 && _params.at(name)._valid;
415 366652586 : }
416 :
417 : bool
418 2559737 : InputParameters::isParamSetByAddParam(const std::string & name_in) const
419 : {
420 2559737 : const auto name = checkForRename(name_in);
421 5119474 : return _params.count(name) > 0 && _params.at(name)._set_by_add_param;
422 2559737 : }
423 :
424 : bool
425 6733705 : InputParameters::isParamDeprecated(const std::string & name_in) const
426 : {
427 6733705 : const auto name = checkForRename(name_in);
428 13467410 : return _params.count(name) > 0 && !_params.at(name)._deprecation_message.empty();
429 6733705 : }
430 :
431 : bool
432 2245130 : InputParameters::areAllRequiredParamsValid() const
433 : {
434 37927247 : for (const auto & it : *this)
435 35793808 : if (isParamRequired(it.first) && !isParamValid(it.first))
436 111691 : return false;
437 2133439 : return true;
438 : }
439 :
440 : bool
441 216792155 : InputParameters::isPrivate(const std::string & name_in) const
442 : {
443 216792155 : const auto name = checkForRename(name_in);
444 433584310 : return _params.count(name) > 0 && _params.at(name)._is_private;
445 216792155 : }
446 :
447 : void
448 23865969 : InputParameters::declareControllable(const std::string & input_names,
449 : std::set<ExecFlagType> execute_flags)
450 : {
451 23865969 : std::vector<std::string> names;
452 23865969 : MooseUtils::tokenize<std::string>(input_names, names, 1, " ");
453 47862962 : for (auto & name_in : names)
454 : {
455 23996994 : const auto name = checkForRename(name_in);
456 23996994 : auto map_iter = _params.find(name);
457 23996994 : if (map_iter != _params.end()) // error is handled by checkParams method
458 : {
459 23996993 : map_iter->second._controllable = true;
460 23996993 : map_iter->second._controllable_flags = execute_flags;
461 : }
462 : else
463 1 : mooseError("The input parameter '",
464 : name,
465 : "' does not exist, thus cannot be marked as controllable.");
466 23996994 : }
467 23865969 : }
468 :
469 : bool
470 138362903 : InputParameters::isControllable(const std::string & name_in) const
471 : {
472 138362903 : const auto name = checkForRename(name_in);
473 276725806 : return _params.count(name) > 0 && _params.at(name)._controllable;
474 138362903 : }
475 :
476 : const std::set<ExecFlagType> &
477 1440618 : InputParameters::getControllableExecuteOnTypes(const std::string & name_in) const
478 : {
479 1440618 : const auto name = checkForRename(name_in);
480 2881236 : return at(name)._controllable_flags;
481 1440618 : }
482 :
483 : void
484 43855960 : InputParameters::registerBase(const std::string & value)
485 : {
486 43855960 : InputParameters::set<std::string>(MooseBase::moose_base_param) = value;
487 43855960 : _params[MooseBase::moose_base_param]._is_private = true;
488 43855960 : }
489 :
490 : bool
491 23590015 : InputParameters::hasBase() const
492 : {
493 23590015 : return have_parameter<std::string>(MooseBase::moose_base_param);
494 : }
495 :
496 : const std::string &
497 30100932 : InputParameters::getBase() const
498 : {
499 30100932 : if (!have_parameter<std::string>(MooseBase::moose_base_param))
500 0 : mooseError("InputParameters::getBase(): Parameters do not have base; one needs to be set with "
501 : "registerBase()");
502 30100932 : return get<std::string>(MooseBase::moose_base_param);
503 : }
504 :
505 : void
506 18305287 : InputParameters::registerSystemAttributeName(const std::string & value)
507 : {
508 18305287 : InputParameters::set<std::string>("_moose_warehouse_system_name") = value;
509 36610574 : _params["_moose_warehouse_system_name"]._is_private = true;
510 18305287 : }
511 :
512 : const std::string &
513 316099 : InputParameters::getSystemAttributeName() const
514 : {
515 : mooseAssert(have_parameter<std::string>("_moose_warehouse_system_name"),
516 : "SystemAttributeName is not available! Call 'registerSystemAttributeName' (usually "
517 : "in the validParams function) before you try accessing it!");
518 316099 : return Parameters::get<std::string>("_moose_warehouse_system_name");
519 : }
520 :
521 : void
522 0 : InputParameters::registerBuildableTypes(const std::string & names)
523 : {
524 0 : _buildable_types.clear();
525 0 : MooseUtils::tokenize(names, _buildable_types, 1, " \t\n\v\f\r"); // tokenize on whitespace
526 0 : }
527 :
528 : void
529 8251125 : InputParameters::addRelationshipManager(
530 : const std::string & name,
531 : Moose::RelationshipManagerType rm_type,
532 : Moose::RelationshipManagerInputParameterCallback input_parameter_callback)
533 : {
534 8251125 : _buildable_rm_types.emplace_back(name, rm_type, input_parameter_callback);
535 8251125 : }
536 :
537 : const std::vector<std::string> &
538 21499771 : InputParameters::getBuildableTypes() const
539 : {
540 21499771 : return _buildable_types;
541 : }
542 :
543 : const std::vector<std::tuple<std::string,
544 : Moose::RelationshipManagerType,
545 : Moose::RelationshipManagerInputParameterCallback>> &
546 2960239 : InputParameters::getBuildableRelationshipManagerTypes() const
547 : {
548 2960239 : return _buildable_rm_types;
549 : }
550 :
551 : void
552 0 : InputParameters::collapseSyntaxNesting(bool collapse)
553 : {
554 0 : _collapse_nesting = collapse;
555 0 : }
556 :
557 : bool
558 395553 : InputParameters::collapseSyntaxNesting() const
559 : {
560 395553 : return _collapse_nesting;
561 : }
562 :
563 : void
564 0 : InputParameters::mooseObjectSyntaxVisibility(bool visibility)
565 : {
566 0 : _moose_object_syntax_visibility = visibility;
567 0 : }
568 :
569 : bool
570 454421 : InputParameters::mooseObjectSyntaxVisibility() const
571 : {
572 454421 : return _moose_object_syntax_visibility;
573 : }
574 :
575 : #define dynamicCastRangeCheck(type, up_type, long_name, short_name, param) \
576 : do \
577 : { \
578 : libMesh::Parameters::Value * val = MooseUtils::get(param); \
579 : if (const auto scalar_p = dynamic_cast<InputParameters::Parameter<type> *>(val)) \
580 : error = rangeCheck<type, up_type>(long_name, short_name, scalar_p, false); \
581 : if (const auto vector_p = dynamic_cast<InputParameters::Parameter<std::vector<type>> *>(val)) \
582 : error = rangeCheck<type, up_type>(long_name, short_name, vector_p, false); \
583 : } while (0)
584 :
585 : #define checkMooseType(param_type, name) \
586 : if (have_parameter<param_type>(name) || have_parameter<std::vector<param_type>>(name)) \
587 : error = "non-controllable type '" + type(name) + "' for parameter '" + \
588 : paramFullpath(param_name) + "' marked controllable";
589 :
590 : void
591 5568908 : InputParameters::checkParams(const std::string & parsing_syntax)
592 : {
593 5568908 : const std::string parampath = blockFullpath() != "" ? blockFullpath() : parsing_syntax;
594 5568908 : std::vector<std::pair<const hit::Node *, std::string>> errors;
595 :
596 : // Required parameters
597 5568908 : std::vector<std::string> required_param_errors;
598 145561907 : for (const auto & it : *this)
599 : {
600 139992999 : const auto param_name = checkForRename(it.first);
601 139992999 : if (!isParamValid(param_name) && isParamRequired(param_name))
602 : {
603 : // check if an old, deprecated name exists for this parameter that may be specified
604 36 : auto oit = _new_to_deprecated_coupled_vars.find(param_name);
605 36 : if (oit != _new_to_deprecated_coupled_vars.end() && isParamValid(oit->second))
606 0 : continue;
607 :
608 108 : required_param_errors.push_back("missing required parameter '" + parampath + "/" +
609 72 : param_name + "'\n\tDoc String: \"" +
610 144 : getDocString(param_name) + "\"");
611 : }
612 139992999 : }
613 :
614 5568908 : if (required_param_errors.size())
615 36 : mooseError(MooseUtils::stringJoin(required_param_errors, "\n"));
616 :
617 : // Range checked parameters
618 145560270 : for (const auto & it : *this)
619 : {
620 139991435 : const std::string long_name(parampath + "/" + it.first);
621 :
622 139991435 : std::optional<std::pair<bool, std::string>> error;
623 139991435 : dynamicCastRangeCheck(Real, Real, long_name, it.first, it.second);
624 139991435 : dynamicCastRangeCheck(int, long, long_name, it.first, it.second);
625 139991435 : dynamicCastRangeCheck(long, long, long_name, it.first, it.second);
626 139991435 : dynamicCastRangeCheck(unsigned int, long, long_name, it.first, it.second);
627 :
628 139991435 : if (error)
629 : {
630 37 : if (error->first)
631 38 : paramError(it.first, error->second);
632 : else
633 0 : mooseError("For range checked parameter '" + it.first + "': " + error->second);
634 : }
635 139991400 : }
636 :
637 : // Controllable parameters
638 6499846 : for (const auto & param_name : getControllableParameters())
639 : {
640 931013 : if (isPrivate(param_name))
641 1 : paramError(param_name,
642 5 : "private parameter '" + paramFullpath(param_name) + "' marked controllable");
643 :
644 931012 : std::optional<std::string> error;
645 931012 : checkMooseType(NonlinearVariableName, param_name);
646 931012 : checkMooseType(AuxVariableName, param_name);
647 931012 : checkMooseType(VariableName, param_name);
648 931012 : checkMooseType(BoundaryName, param_name);
649 931012 : checkMooseType(SubdomainName, param_name);
650 931012 : checkMooseType(PostprocessorName, param_name);
651 931012 : checkMooseType(VectorPostprocessorName, param_name);
652 931012 : checkMooseType(UserObjectName, param_name);
653 931012 : checkMooseType(MaterialPropertyName, param_name);
654 931012 : if (error)
655 2 : paramError(param_name, *error);
656 6499847 : }
657 5568842 : }
658 :
659 : void
660 5535671 : InputParameters::finalize(const std::string & parsing_syntax)
661 : {
662 : mooseAssert(!isFinalized(), "Already finalized");
663 :
664 5535671 : checkParams(parsing_syntax);
665 :
666 : // Helper for setting the absolute paths for each set file name parameter
667 256592 : const auto set_absolute_path = [this](const std::string & param_name, auto & value)
668 : {
669 : // We don't need to set a path if nothing is there
670 256592 : if (value.empty())
671 237733 : return;
672 :
673 18997 : std::filesystem::path value_path = std::string(value);
674 : // Is already absolute, nothing to do
675 18997 : if (value_path.is_absolute())
676 138 : return;
677 :
678 : // The base by which to make things relative to
679 18859 : const auto file_base = getFileBase(param_name);
680 18859 : value = std::filesystem::absolute(file_base / value_path).c_str();
681 5554600 : };
682 :
683 : // Set the absolute path for each file name typed parameter
684 144671542 : for (const auto & [param_name, param_value] : *this)
685 : {
686 : #define set_if_filename(type) \
687 : else if (auto type_value = dynamic_cast<Parameters::Parameter<type> *>(param_value.get())) \
688 : set_absolute_path(param_name, type_value->set()); \
689 : else if (auto type_values = dynamic_cast<Parameters::Parameter<std::vector<type>> *>( \
690 : param_value.get())) for (auto & value : type_values->set()) \
691 : set_absolute_path(param_name, value)
692 :
693 : if (false)
694 : ;
695 : // Note that we explicitly skip DataFileName here because we do not want absolute
696 : // file paths for data files, as they're searched in the data directories
697 139145131 : set_if_filename(FileName);
698 139038512 : set_if_filename(FileNameNoExtension);
699 138911885 : set_if_filename(MeshFileName);
700 138866412 : set_if_filename(MatrixFileName);
701 : #undef set_if_filename
702 : // Set paths for data files
703 138864092 : else if (auto data_file_name =
704 138864092 : dynamic_cast<Parameters::Parameter<DataFileName> *>(param_value.get()))
705 : {
706 190 : Moose::DataFileUtils::Path found_path;
707 190 : std::optional<std::string> error;
708 :
709 : // Catch this so that we can add additional error context if it fails (the param path)
710 190 : const auto throw_on_error_before = Moose::_throw_on_error;
711 190 : Moose::_throw_on_error = true;
712 : try
713 : {
714 206 : found_path = Moose::DataFileUtils::getPath(data_file_name->get(), getFileBase(param_name));
715 : }
716 4 : catch (std::exception & e)
717 : {
718 4 : error = e.what();
719 4 : }
720 190 : Moose::_throw_on_error = throw_on_error_before;
721 :
722 190 : if (error)
723 4 : paramError(param_name, *error);
724 :
725 : // Set the value to the absolute searched path
726 186 : data_file_name->set() = found_path.path;
727 : // And store the path in metadata so that we can dump it later
728 186 : at(param_name)._data_file_name_path = found_path;
729 186 : }
730 : }
731 :
732 5535599 : _finalized = true;
733 5535599 : }
734 :
735 : std::filesystem::path
736 19049 : InputParameters::getFileBase(const std::optional<std::string> & param_name) const
737 : {
738 : mooseAssert(!have_parameter<std::string>("_app_name"),
739 : "Not currently setup to work with app FileName parameters");
740 :
741 19049 : const hit::Node * hit_node = nullptr;
742 :
743 : // Context from the individual parameter
744 19049 : if (param_name)
745 19049 : hit_node = getHitNode(*param_name);
746 : // Context from the parameters
747 19049 : if (!hit_node)
748 1001 : hit_node = getHitNode();
749 : // No hit node, so use the cwd (no input files)
750 19049 : if (!hit_node)
751 136 : return std::filesystem::current_path();
752 :
753 : // Find any context that isn't command line arguments
754 19436 : while (hit_node && hit_node->filename() == "CLI_ARGS")
755 523 : hit_node = hit_node->parent();
756 :
757 : // Failed to find a node up the tree that isn't a command line argument
758 18913 : if (!hit_node)
759 : {
760 : const std::string error = "Input context was set via a command-line argument and does not have "
761 0 : "sufficient context for determining a file path.";
762 0 : if (param_name)
763 0 : paramError(*param_name, error);
764 : else
765 0 : mooseError(error);
766 0 : }
767 :
768 18913 : return std::filesystem::absolute(std::filesystem::path(hit_node->filename()).parent_path());
769 : }
770 :
771 : bool
772 2154873 : InputParameters::isRangeChecked(const std::string & param_name) const
773 : {
774 2154873 : const auto name = checkForRename(param_name);
775 4309746 : return !_params.find(name)->second._range_function.empty();
776 2154873 : }
777 :
778 : std::string
779 3 : InputParameters::rangeCheckedFunction(const std::string & param_name) const
780 : {
781 3 : const auto name = checkForRename(param_name);
782 6 : return _params.at(name)._range_function;
783 3 : }
784 :
785 : bool
786 2154499 : InputParameters::hasDefault(const std::string & param_name) const
787 : {
788 2154499 : const auto name = checkForRename(param_name);
789 2154499 : if (hasDefaultCoupledValue(name))
790 0 : return true;
791 : // If it has a default, it's already valid
792 2154499 : else if (isParamSetByAddParam(name))
793 2 : return true;
794 2154497 : else if (isParamValid(name))
795 0 : mooseError("No way to know if the parameter '", param_name, "' has a default");
796 : else
797 2154497 : return false;
798 2154499 : }
799 :
800 : bool
801 2289692 : InputParameters::hasCoupledValue(const std::string & coupling_name) const
802 : {
803 2289692 : return _coupled_vars.find(coupling_name) != _coupled_vars.end();
804 : }
805 :
806 : bool
807 9138661 : InputParameters::hasDefaultCoupledValue(const std::string & coupling_name) const
808 : {
809 9144888 : return _params.count(coupling_name) > 0 && _params.at(coupling_name)._have_coupled_default &&
810 9144888 : _coupled_vars.count(coupling_name) > 0;
811 : }
812 :
813 : void
814 998 : InputParameters::defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i)
815 : {
816 998 : const auto actual_name = checkForRename(coupling_name);
817 998 : _params[actual_name]._coupled_default.resize(i + 1);
818 998 : _params[actual_name]._coupled_default[i] = value;
819 998 : _params[actual_name]._have_coupled_default = true;
820 998 : }
821 :
822 : Real
823 968705 : InputParameters::defaultCoupledValue(const std::string & coupling_name, unsigned int i) const
824 : {
825 968705 : auto value_it = _params.find(coupling_name);
826 :
827 968705 : if (value_it == _params.end() || !value_it->second._have_coupled_default)
828 0 : mooseError("Attempted to retrieve default value for coupled variable '",
829 : coupling_name,
830 : "' when none was provided. \n\nThere are three reasons why this may have "
831 : "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
832 : "to provide a default value. \n 2. This should have been a required coupled "
833 : "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
834 : "coupled value should have been properly guarded with isCoupled()\n");
835 :
836 1926410 : return value_it->second._coupled_default.at(i);
837 : }
838 :
839 : unsigned int
840 232613 : InputParameters::numberDefaultCoupledValues(const std::string & coupling_name) const
841 : {
842 232613 : auto value_it = _params.find(coupling_name);
843 232613 : if (value_it == _params.end())
844 0 : mooseError("Attempted to retrieve default value for coupled variable '",
845 : coupling_name,
846 : "' when none was provided.");
847 465226 : return value_it->second._coupled_default.size();
848 : }
849 :
850 : std::map<std::string, std::pair<std::string, std::string>>
851 2367548 : InputParameters::getAutoBuildVectors() const
852 : {
853 2367548 : std::map<std::string, std::pair<std::string, std::string>> abv;
854 66820658 : for (auto it = _params.begin(); it != _params.end(); ++it)
855 : {
856 64453110 : if (!it->second._autobuild_vecs.first.empty())
857 2 : abv[it->first] = it->second._autobuild_vecs;
858 : }
859 2367548 : return abv;
860 0 : }
861 :
862 : std::string
863 7139803 : InputParameters::type(const std::string & name_in) const
864 : {
865 7139803 : const auto name = checkForRename(name_in);
866 7139803 : if (!_values.count(name))
867 0 : mooseError("Parameter \"", name, "\" not found.\n\n", *this);
868 :
869 7139803 : if (_coupled_vars.find(name) != _coupled_vars.end())
870 367944 : return "std::vector<VariableName>";
871 6955831 : else if (_params.count(name) > 0 && !_params.at(name)._custom_type.empty())
872 7725 : return _params.at(name)._custom_type;
873 6948106 : return _values.at(name)->type();
874 7139803 : }
875 :
876 : std::string
877 1592259 : InputParameters::getMooseType(const std::string & name_in) const
878 : {
879 1592259 : const auto name = checkForRename(name_in);
880 1592259 : std::string var;
881 :
882 1592259 : if (have_parameter<VariableName>(name))
883 77451 : var = get<VariableName>(name);
884 1514808 : else if (have_parameter<NonlinearVariableName>(name))
885 789804 : var = get<NonlinearVariableName>(name);
886 725004 : else if (have_parameter<LinearVariableName>(name))
887 17862 : var = get<LinearVariableName>(name);
888 707142 : else if (have_parameter<AuxVariableName>(name))
889 452150 : var = get<AuxVariableName>(name);
890 254992 : else if (have_parameter<PostprocessorName>(name))
891 0 : var = get<PostprocessorName>(name);
892 254992 : else if (have_parameter<VectorPostprocessorName>(name))
893 0 : var = get<VectorPostprocessorName>(name);
894 254992 : else if (have_parameter<FunctionName>(name))
895 0 : var = get<FunctionName>(name);
896 254992 : else if (have_parameter<UserObjectName>(name))
897 0 : var = get<UserObjectName>(name);
898 254992 : else if (have_parameter<MaterialPropertyName>(name))
899 0 : var = get<MaterialPropertyName>(name);
900 254992 : else if (have_parameter<std::string>(name))
901 0 : var = get<std::string>(name);
902 :
903 3184518 : return var;
904 1592259 : }
905 :
906 : std::vector<std::string>
907 881599 : InputParameters::getVecMooseType(const std::string & name_in) const
908 : {
909 881599 : const auto name = checkForRename(name_in);
910 881599 : std::vector<std::string> svars;
911 :
912 881599 : if (have_parameter<std::vector<VariableName>>(name))
913 : {
914 881591 : std::vector<VariableName> vars = get<std::vector<VariableName>>(name);
915 881591 : std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
916 881591 : }
917 8 : else if (have_parameter<std::vector<NonlinearVariableName>>(name))
918 : {
919 0 : std::vector<NonlinearVariableName> vars = get<std::vector<NonlinearVariableName>>(name);
920 0 : std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
921 0 : }
922 8 : else if (have_parameter<std::vector<AuxVariableName>>(name))
923 : {
924 0 : std::vector<AuxVariableName> vars = get<std::vector<AuxVariableName>>(name);
925 0 : std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
926 0 : }
927 8 : else if (have_parameter<std::vector<MaterialPropertyName>>(name))
928 : {
929 0 : std::vector<MaterialPropertyName> vars = get<std::vector<MaterialPropertyName>>(name);
930 0 : std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
931 0 : }
932 8 : else if (have_parameter<std::vector<std::string>>(name))
933 : {
934 0 : std::vector<std::string> vars = get<std::vector<std::string>>(name);
935 0 : std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
936 0 : }
937 :
938 1763198 : return svars;
939 881599 : }
940 :
941 : bool
942 18793 : InputParameters::isMooseBaseObject() const
943 : {
944 37550 : return have_parameter<std::string>(MooseBase::type_param) &&
945 37550 : get<std::string>(MooseBase::type_param).size() &&
946 37514 : have_parameter<std::string>(MooseBase::name_param);
947 : }
948 :
949 : const std::string &
950 12472323 : InputParameters::getObjectType() const
951 : {
952 12472323 : if (!have_parameter<std::string>(MooseBase::type_param))
953 0 : ::mooseError("InputParameters::getObjectType(): Missing '", MooseBase::type_param, "' param");
954 12472323 : return get<std::string>(MooseBase::type_param);
955 : }
956 :
957 : const std::string &
958 13586635 : InputParameters::getObjectName() const
959 : {
960 13586635 : if (!have_parameter<std::string>(MooseBase::name_param))
961 0 : ::mooseError("InputParameters::getObjectName(): Missing '", MooseBase::name_param, "' param");
962 13586635 : return get<std::string>(MooseBase::name_param);
963 : }
964 :
965 : void
966 161601866 : InputParameters::addParamNamesToGroup(const std::string & space_delim_names,
967 : const std::string group_name)
968 : {
969 161601866 : std::vector<std::string> elements;
970 161601866 : MooseUtils::tokenize(space_delim_names, elements, 1, " \t\n\v\f\r"); // tokenize on whitespace
971 :
972 : // Since we don't require types (templates) for this method, we need
973 : // to get a raw list of parameter names to compare against.
974 161601866 : std::set<std::string> param_names;
975 2513147490 : for (const auto & it : *this)
976 2351545624 : param_names.insert(it.first);
977 :
978 527849582 : for (const auto & param_name : elements)
979 366247716 : if (_params.count(param_name) > 0)
980 366247716 : _params[param_name]._group = group_name;
981 : else
982 0 : mooseError("Unable to find a parameter with name: ",
983 : param_name,
984 : " when adding to group ",
985 : group_name,
986 0 : '.');
987 161601866 : }
988 :
989 : void
990 0 : InputParameters::renameParameterGroup(const std::string & old_name, const std::string & new_name)
991 : {
992 0 : for (auto & param : _params)
993 0 : if (param.second._group == old_name)
994 0 : param.second._group = new_name;
995 0 : }
996 :
997 : void
998 1916914 : InputParameters::setGlobalCommandLineParam(const std::string & name)
999 : {
1000 1916914 : auto & cl_data = at(checkForRename(name))._cl_data;
1001 1916914 : if (!cl_data)
1002 1 : mooseError("InputParameters::setGlobalCommandLineParam: The parameter '",
1003 : name,
1004 : "' is not a command line parameter");
1005 1916913 : cl_data->global = true;
1006 1916913 : }
1007 :
1008 : bool
1009 2 : InputParameters::isCommandLineParameter(const std::string & name) const
1010 : {
1011 2 : return at(checkForRename(name))._cl_data.has_value();
1012 : }
1013 :
1014 : std::optional<InputParameters::CommandLineMetadata>
1015 9681168 : InputParameters::queryCommandLineMetadata(const std::string & name) const
1016 : {
1017 9681168 : const auto & cl_data = at(checkForRename(name))._cl_data;
1018 9681168 : if (!cl_data)
1019 4139740 : return {};
1020 5541428 : return *cl_data;
1021 : }
1022 :
1023 : const InputParameters::CommandLineMetadata &
1024 22 : InputParameters::getCommandLineMetadata(const std::string & name) const
1025 : {
1026 22 : const auto & cl_data = at(checkForRename(name))._cl_data;
1027 22 : if (!cl_data)
1028 1 : mooseError("InputParameters::getCommandLineMetadata: The parameter '",
1029 : name,
1030 : "' is not a command line parameter");
1031 21 : return *cl_data;
1032 : }
1033 :
1034 : void
1035 457591 : InputParameters::commandLineParamSet(const std::string & name, const CommandLineParamSetKey)
1036 : {
1037 457591 : auto & cl_data = at(checkForRename(name))._cl_data;
1038 457591 : if (!cl_data)
1039 1 : mooseError("InputParameters::commandLineParamSet: The parameter '",
1040 : name,
1041 : "' is not a command line parameter");
1042 457590 : cl_data->set_by_command_line = true;
1043 457590 : }
1044 :
1045 : std::string
1046 7138118 : InputParameters::getGroupName(const std::string & param_name_in) const
1047 : {
1048 7138118 : const auto param_name = checkForRename(param_name_in);
1049 7138118 : auto it = _params.find(param_name);
1050 7138118 : if (it != _params.end())
1051 7138118 : return it->second._group;
1052 0 : return std::string();
1053 7138118 : }
1054 :
1055 : void
1056 628932 : InputParameters::applyParameters(const InputParameters & common,
1057 : const std::vector<std::string> & exclude,
1058 : const bool allow_private)
1059 : {
1060 : // If we're applying all of the things, also associate the top level hit node
1061 628932 : if (exclude.empty() && !getHitNode() && common.getHitNode())
1062 195126 : setHitNode(*common.getHitNode(), {});
1063 :
1064 : // Loop through the common parameters
1065 41335340 : for (const auto & it : common)
1066 : {
1067 : // Common parameter name
1068 40706408 : const std::string & common_name = it.first;
1069 : // Continue to next parameter, if the current is in list of excluded parameters
1070 40706408 : if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1071 111630 : continue;
1072 :
1073 40594778 : applyParameter(common, common_name, allow_private);
1074 : }
1075 :
1076 : // Loop through the coupled variables
1077 628932 : for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
1078 630480 : it != common.coupledVarsEnd();
1079 1548 : ++it)
1080 : {
1081 : // Variable name
1082 1548 : const std::string var_name = *it;
1083 :
1084 : // Continue to next variable, if the current is in list of excluded parameters
1085 1548 : if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1086 0 : continue;
1087 :
1088 1548 : applyCoupledVar(common, var_name);
1089 1548 : }
1090 628932 : }
1091 :
1092 : void
1093 126194 : InputParameters::applySpecificParameters(const InputParameters & common,
1094 : const std::vector<std::string> & include,
1095 : bool allow_private)
1096 : {
1097 : // Loop through the common parameters
1098 2768703 : for (const auto & it : common)
1099 : {
1100 : // Common parameter name
1101 2642509 : const std::string & common_name = it.first;
1102 :
1103 : // Continue to next parameter, if the current is not in list of included parameters
1104 2642509 : if (std::find(include.begin(), include.end(), common_name) == include.end())
1105 2271529 : continue;
1106 :
1107 370980 : applyParameter(common, common_name, allow_private);
1108 : }
1109 :
1110 : // Loop through the coupled variables
1111 126194 : for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
1112 126194 : it != common.coupledVarsEnd();
1113 0 : ++it)
1114 : {
1115 : // Variable name
1116 0 : const std::string var_name = *it;
1117 :
1118 : // Continue to next variable, if the current is not in list of included parameters
1119 0 : if (std::find(include.begin(), include.end(), var_name) == include.end())
1120 0 : continue;
1121 :
1122 0 : applyCoupledVar(common, var_name);
1123 0 : }
1124 126194 : }
1125 :
1126 : void
1127 1548 : InputParameters::applyCoupledVar(const InputParameters & common, const std::string & var_name)
1128 : {
1129 : // Disable the display of deprecated message when applying common parameters, this avoids a dump
1130 : // of messages
1131 1548 : _show_deprecated_message = false;
1132 :
1133 : // If the local parameters has a coupled variable, populate it with the value from the common
1134 : // parameters, if the common parameters has the coupled variable too
1135 1548 : if (hasCoupledValue(var_name))
1136 : {
1137 1544 : if (common.hasDefaultCoupledValue(var_name))
1138 : {
1139 : // prepare a vector of default coupled values
1140 0 : std::vector<Real> defaults(common.numberDefaultCoupledValues(var_name));
1141 0 : for (unsigned int j = 0; j < common.numberDefaultCoupledValues(var_name); ++j)
1142 0 : defaults[j] = common.defaultCoupledValue(var_name, j);
1143 0 : addCoupledVar(var_name, defaults, common.getDocString(var_name));
1144 0 : }
1145 1544 : else if (common.hasCoupledValue(var_name))
1146 1544 : addCoupledVar(var_name, common.getDocString(var_name));
1147 : }
1148 :
1149 : // Enable deprecated message printing
1150 1548 : _show_deprecated_message = true;
1151 1548 : }
1152 :
1153 : void
1154 40965906 : InputParameters::applyParameter(const InputParameters & common,
1155 : const std::string & common_name,
1156 : bool allow_private,
1157 : bool override_default)
1158 : {
1159 : // Disable the display of deprecated message when applying common parameters, this avoids a dump
1160 : // of messages
1161 40965906 : _show_deprecated_message = false;
1162 :
1163 40965906 : const auto local_name = checkForRename(common_name);
1164 :
1165 : // Extract the properties from the local parameter for the current common parameter name
1166 40965906 : const bool local_exist = _values.find(local_name) != _values.end();
1167 40965906 : const bool local_set = _params.count(local_name) > 0 && !_params[local_name]._set_by_add_param;
1168 40965906 : const bool local_priv = allow_private ? false : isPrivate(local_name);
1169 40965906 : const bool local_valid = isParamValid(local_name);
1170 :
1171 : // Extract the properties from the common parameter
1172 40965906 : const bool common_exist = common._values.find(common_name) != common._values.end();
1173 40965906 : const bool common_priv = allow_private ? false : common.isPrivate(common_name);
1174 40965906 : const bool common_valid = common.isParamValid(common_name) || override_default;
1175 :
1176 : /* In order to apply a common parameter 4 statements must be satisfied
1177 : * (1) A local parameter must exist with the same name as the common parameter
1178 : * (2) Common parameter must be valid and exist
1179 : * (3) Local parameter must be invalid OR not have been set from its default
1180 : * (4) Both cannot be private
1181 : */
1182 40965906 : if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
1183 10412205 : (!common_priv || !local_priv))
1184 : {
1185 4694400 : remove(local_name);
1186 4694400 : _values[local_name] = common._values.find(common_name)->second->clone();
1187 4694400 : set_attributes(local_name, false);
1188 9388800 : _params[local_name]._set_by_add_param =
1189 4694400 : libmesh_map_find(common._params, common_name)._set_by_add_param;
1190 : // Keep track of where this param came from if we can. This will enable us to
1191 : // produce param errors from objects created within an action that link to
1192 : // the parameter in the action
1193 4694400 : at(local_name)._hit_node = common.getHitNode(common_name);
1194 : }
1195 36271506 : else if (!local_exist && !common_exist)
1196 1 : mooseError("InputParameters::applyParameter(): Attempted to apply invalid parameter \"",
1197 : common_name,
1198 : "\"");
1199 :
1200 : // Enable deprecated message printing
1201 40965905 : _show_deprecated_message = true;
1202 40965906 : }
1203 :
1204 : ///Deprecated method
1205 : bool
1206 0 : InputParameters::paramSetByUser(const std::string & name) const
1207 : {
1208 0 : mooseDeprecated("paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
1209 0 : return isParamSetByUser(name);
1210 : }
1211 :
1212 : bool
1213 4554539 : InputParameters::isParamSetByUser(const std::string & name_in) const
1214 : {
1215 4554539 : const auto name = checkForRename(name_in);
1216 : // Invalid; for sure not set by the user
1217 4554539 : if (!isParamValid(name))
1218 1247976 : return false;
1219 : // Parameter is not located in the list (called Parameters::set)
1220 3306563 : if (!_params.count(name))
1221 0 : return false;
1222 : // Special case for a command line option, which is a private parameter
1223 3306563 : if (const auto cl_data = queryCommandLineMetadata(name))
1224 3306563 : return cl_data->set_by_command_line;
1225 : // Not a command line option, not set by addParam and not private
1226 2805285 : return !_params.at(name)._set_by_add_param && !_params.at(name)._is_private;
1227 4554539 : }
1228 :
1229 : bool
1230 2 : InputParameters::isParamDefined(const std::string & name_in) const
1231 : {
1232 2 : const auto name = checkForRename(name_in);
1233 4 : return _params.count(name) > 0;
1234 2 : }
1235 :
1236 : const std::string &
1237 2154879 : InputParameters::getDescription(const std::string & name_in) const
1238 : {
1239 2154879 : const auto name = checkForRename(name_in);
1240 2154879 : auto it = _params.find(name);
1241 2154879 : if (it == _params.end())
1242 0 : mooseError("No parameter exists with the name ", name);
1243 4309758 : return it->second._doc_string;
1244 2154879 : }
1245 :
1246 : template <>
1247 : void
1248 1799457 : InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
1249 : const MooseEnum & moose_enum,
1250 : const std::string & doc_string)
1251 : {
1252 1799457 : InputParameters::set<MooseEnum>(name) = moose_enum; // valid parameter is set by set_attributes
1253 1799457 : auto & metadata = _params[name];
1254 1799457 : metadata._required = true;
1255 1799457 : metadata._doc_string = doc_string;
1256 1799457 : }
1257 :
1258 : template <>
1259 : void
1260 2 : InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1261 : const MultiMooseEnum & moose_enum,
1262 : const std::string & doc_string)
1263 : {
1264 2 : InputParameters::set<MultiMooseEnum>(name) =
1265 2 : moose_enum; // valid parameter is set by set_attributes
1266 2 : auto & metadata = _params[name];
1267 2 : metadata._required = true;
1268 2 : metadata._doc_string = doc_string;
1269 2 : }
1270 :
1271 : template <>
1272 : void
1273 2 : InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1274 : const std::string & name,
1275 : const std::vector<MooseEnum> & moose_enums,
1276 : const std::string & doc_string)
1277 : {
1278 2 : InputParameters::set<std::vector<MooseEnum>>(name) =
1279 2 : moose_enums; // valid parameter is set by set_attributes
1280 2 : auto & metadata = _params[name];
1281 2 : metadata._required = true;
1282 2 : metadata._doc_string = doc_string;
1283 2 : }
1284 :
1285 : template <>
1286 : void
1287 14314 : InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
1288 : const std::string & name,
1289 : const std::vector<MultiMooseEnum> & moose_enums,
1290 : const std::string & doc_string)
1291 : {
1292 : mooseAssert(
1293 : moose_enums.size() == 1,
1294 : "Only 1 MultiMooseEnum is supported in addRequiredParam<std::vector<MultiMooseEnum>> for " +
1295 : name);
1296 : mooseAssert(!moose_enums[0].items().empty(),
1297 : "The MultiMooseEnum in addRequiredParam<std::vector<MultiMooseEnum>> is empty for " +
1298 : name);
1299 14314 : InputParameters::set<std::vector<MultiMooseEnum>>(name) =
1300 14314 : moose_enums; // valid parameter is set by set_attributes
1301 14314 : auto & metadata = _params[name];
1302 14314 : metadata._required = true;
1303 14314 : metadata._doc_string = doc_string;
1304 14314 : }
1305 :
1306 : template <>
1307 : void
1308 0 : InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1309 : const std::string & /*doc_string*/)
1310 : {
1311 0 : mooseError("You must supply a MooseEnum object when using addParam, even if the parameter is not "
1312 : "required!");
1313 : }
1314 :
1315 : template <>
1316 : void
1317 0 : InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1318 : const std::string & /*doc_string*/)
1319 : {
1320 0 : mooseError("You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1321 : "is not required!");
1322 : }
1323 :
1324 : template <>
1325 : void
1326 0 : InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1327 : const std::string & /*doc_string*/)
1328 : {
1329 0 : mooseError("You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1330 : "parameter is not required!");
1331 : }
1332 :
1333 : template <>
1334 : void
1335 0 : InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1336 : const std::string & /*doc_string*/)
1337 : {
1338 0 : mooseError(
1339 : "You must supply a vector of MultiMooseEnum object(s) when using addParam, even if the "
1340 : "parameter is not required!");
1341 : }
1342 :
1343 : template <>
1344 : void
1345 0 : InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1346 : const std::string & /*doc_string*/)
1347 : {
1348 0 : mooseError("You must supply a vector of MultiMooseEnum object(s) when using addRequiredParam!");
1349 : }
1350 :
1351 : template <>
1352 : void
1353 0 : InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/)
1354 : {
1355 0 : mooseError("You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1356 : "is not required!");
1357 : }
1358 :
1359 : template <>
1360 : void
1361 0 : InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/)
1362 : {
1363 0 : mooseError("You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1364 : "parameter is not required!");
1365 : }
1366 :
1367 : template <>
1368 : void
1369 0 : InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
1370 : const std::string & /*doc_string*/,
1371 : const std::string & /*deprecation_message*/)
1372 : {
1373 0 : mooseError("You must supply a MooseEnum object and the deprecation string when using "
1374 : "addDeprecatedParam, even if the parameter is not required!");
1375 : }
1376 :
1377 : template <>
1378 : void
1379 0 : InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
1380 : const std::string & /*doc_string*/,
1381 : const std::string & /*deprecation_message*/)
1382 : {
1383 0 : mooseError("You must supply a MultiMooseEnum object and the deprecation string when using "
1384 : "addDeprecatedParam, even if the parameter is not required!");
1385 : }
1386 :
1387 : template <>
1388 : void
1389 0 : InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1390 : const std::string & /*name*/,
1391 : const std::string & /*doc_string*/,
1392 : const std::string & /*deprecation_message*/)
1393 : {
1394 0 : mooseError("You must supply a vector of MooseEnum object(s) and the deprecation string when "
1395 : "using addDeprecatedParam, even if the parameter is not required!");
1396 : }
1397 :
1398 : template <>
1399 : void
1400 159230 : InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & /*name*/,
1401 : PostprocessorName & l_value,
1402 : const Real & r_value)
1403 : {
1404 : // Assign the default value so that it appears in the dump
1405 159230 : std::ostringstream oss;
1406 159230 : oss << r_value;
1407 159230 : l_value = oss.str();
1408 159230 : }
1409 :
1410 : template <>
1411 : void
1412 182369 : InputParameters::setParamHelper<PostprocessorName, int>(const std::string & /*name*/,
1413 : PostprocessorName & l_value,
1414 : const int & r_value)
1415 : {
1416 : // Assign the default value so that it appears in the dump
1417 182369 : std::ostringstream oss;
1418 182369 : oss << r_value;
1419 182369 : l_value = oss.str();
1420 182369 : }
1421 :
1422 : template <>
1423 : void
1424 43322 : InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1425 : FunctionName & l_value,
1426 : const Real & r_value)
1427 : {
1428 : // Assign the default value so that it appears in the dump
1429 43322 : std::ostringstream oss;
1430 43322 : oss << r_value;
1431 43322 : l_value = oss.str();
1432 43322 : }
1433 :
1434 : template <>
1435 : void
1436 750139 : InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1437 : FunctionName & l_value,
1438 : const int & r_value)
1439 : {
1440 : // Assign the default value so that it appears in the dump
1441 750139 : std::ostringstream oss;
1442 750139 : oss << r_value;
1443 750139 : l_value = oss.str();
1444 750139 : }
1445 :
1446 : template <>
1447 : void
1448 87689 : InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1449 : MaterialPropertyName & l_value,
1450 : const Real & r_value)
1451 : {
1452 : // Assign the default value so that it appears in the dump
1453 87689 : std::ostringstream oss;
1454 87689 : oss << r_value;
1455 87689 : l_value = oss.str();
1456 87689 : }
1457 :
1458 : template <>
1459 : void
1460 146310 : InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1461 : MaterialPropertyName & l_value,
1462 : const int & r_value)
1463 : {
1464 : // Assign the default value so that it appears in the dump
1465 146310 : std::ostringstream oss;
1466 146310 : oss << r_value;
1467 146310 : l_value = oss.str();
1468 146310 : }
1469 :
1470 : template <>
1471 : void
1472 181386 : InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
1473 : MooseFunctorName & l_value,
1474 : const Real & r_value)
1475 : {
1476 : // Assign the default value so that it appears in the dump
1477 181386 : std::ostringstream oss;
1478 181386 : oss << r_value;
1479 181386 : l_value = oss.str();
1480 181386 : }
1481 :
1482 : template <>
1483 : void
1484 331841 : InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
1485 : MooseFunctorName & l_value,
1486 : const int & r_value)
1487 : {
1488 : // Assign the default value so that it appears in the dump
1489 331841 : std::ostringstream oss;
1490 331841 : oss << r_value;
1491 331841 : l_value = oss.str();
1492 331841 : }
1493 :
1494 : template <>
1495 : const MooseEnum &
1496 2104022 : InputParameters::getParamHelper<MooseEnum>(const std::string & name_in,
1497 : const InputParameters & pars)
1498 : {
1499 2104022 : const auto name = pars.checkForRename(name_in);
1500 4208044 : return pars.get<MooseEnum>(name);
1501 2104022 : }
1502 :
1503 : template <>
1504 : const MultiMooseEnum &
1505 135824 : InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name_in,
1506 : const InputParameters & pars)
1507 : {
1508 135824 : const auto name = pars.checkForRename(name_in);
1509 271648 : return pars.get<MultiMooseEnum>(name);
1510 135824 : }
1511 :
1512 : void
1513 7232251 : InputParameters::setReservedValues(const std::string & name_in,
1514 : const std::set<std::string> & reserved)
1515 : {
1516 7232251 : const auto name = checkForRename(name_in);
1517 7232251 : _params[name]._reserved_values = reserved;
1518 7232251 : }
1519 :
1520 : std::set<std::string>
1521 6716208 : InputParameters::reservedValues(const std::string & name_in) const
1522 : {
1523 6716208 : const auto name = checkForRename(name_in);
1524 6716208 : auto it = _params.find(name);
1525 6716208 : if (it == _params.end())
1526 0 : return std::set<std::string>();
1527 6716208 : return it->second._reserved_values;
1528 6716208 : }
1529 :
1530 : std::string
1531 0 : InputParameters::blockLocation() const
1532 : {
1533 0 : if (const auto hit_node = getHitNode())
1534 0 : return hit_node->fileLocation(/* with_column = */ false);
1535 0 : return "";
1536 : }
1537 :
1538 : std::string
1539 15148179 : InputParameters::blockFullpath() const
1540 : {
1541 15148179 : if (const auto hit_node = getHitNode())
1542 14027078 : return hit_node->fullpath();
1543 2242202 : return "";
1544 : }
1545 :
1546 : const hit::Node *
1547 4990448 : InputParameters::getHitNode(const std::string & param) const
1548 : {
1549 4990448 : return at(param)._hit_node;
1550 : }
1551 :
1552 : void
1553 2735539 : InputParameters::setHitNode(const std::string & param,
1554 : const hit::Node & node,
1555 : const InputParameters::SetParamHitNodeKey)
1556 : {
1557 : mooseAssert(node.type() == hit::NodeType::Field, "Must be a field");
1558 2735539 : at(param)._hit_node = &node;
1559 2735539 : }
1560 :
1561 : std::string
1562 32 : InputParameters::inputLocation(const std::string & param) const
1563 : {
1564 32 : if (const auto hit_node = getHitNode(param))
1565 32 : return hit_node->fileLocation(/* with_column = */ false);
1566 0 : return "";
1567 : }
1568 :
1569 : std::string
1570 38 : InputParameters::paramFullpath(const std::string & param) const
1571 : {
1572 38 : if (const auto hit_node = getHitNode(param))
1573 36 : return hit_node->fullpath();
1574 4 : return "";
1575 : }
1576 :
1577 : void
1578 1902734564 : InputParameters::checkParamName(const std::string & name) const
1579 : {
1580 1902734564 : const static pcrecpp::RE valid("[\\w:/]+");
1581 1902734564 : if (!valid.FullMatch(name))
1582 3 : mooseError("Invalid parameter name: '", name, "'");
1583 1902734561 : }
1584 :
1585 : bool
1586 64453544 : InputParameters::shouldIgnore(const std::string & name_in)
1587 : {
1588 64453544 : const auto name = checkForRename(name_in);
1589 64453544 : auto it = _params.find(name);
1590 64453544 : if (it != _params.end())
1591 128907088 : return it->second._ignore;
1592 0 : mooseError("Parameter ", name, " does not exist");
1593 64453544 : }
1594 :
1595 : std::set<std::string>
1596 0 : InputParameters::getGroupParameters(const std::string & group) const
1597 : {
1598 0 : std::set<std::string> names;
1599 0 : for (auto it = _params.begin(); it != _params.end(); ++it)
1600 0 : if (it->second._group == group)
1601 0 : names.emplace(it->first);
1602 0 : return names;
1603 0 : }
1604 :
1605 : std::set<std::string>
1606 219 : InputParameters::getParametersList() const
1607 : {
1608 219 : std::set<std::string> param_set;
1609 2713 : for (auto it = _params.begin(); it != _params.end(); ++it)
1610 2494 : param_set.emplace(it->first);
1611 219 : return param_set;
1612 0 : }
1613 :
1614 : std::set<std::string>
1615 5719602 : InputParameters::getControllableParameters() const
1616 : {
1617 5719602 : std::set<std::string> controllable;
1618 153457379 : for (auto it = _params.begin(); it != _params.end(); ++it)
1619 147737777 : if (it->second._controllable)
1620 932594 : controllable.emplace(it->first);
1621 5719602 : return controllable;
1622 0 : }
1623 :
1624 : std::string
1625 16 : InputParameters::paramLocationPrefix(const std::string & param) const
1626 : {
1627 16 : auto prefix = param + ":";
1628 16 : if (!inputLocation(param).empty())
1629 16 : prefix = inputLocation(param) + ": (" + paramFullpath(param) + ")";
1630 16 : return prefix;
1631 0 : }
1632 :
1633 : std::string
1634 0 : InputParameters::rawParamVal(const std::string & param) const
1635 : {
1636 0 : if (const auto hit_node = getHitNode(param))
1637 0 : return hit_node->strVal();
1638 0 : return "";
1639 : }
1640 :
1641 : std::string
1642 544622 : InputParameters::varName(const std::string & var_param_name,
1643 : const std::string & moose_object_with_var_param_name) const
1644 : {
1645 : // Try the scalar version first
1646 544622 : std::string variable_name = getMooseType(var_param_name);
1647 544622 : if (variable_name == "")
1648 : {
1649 66323 : auto vec = getVecMooseType(var_param_name);
1650 :
1651 : // Catch the (very unlikely) case where a user specifies
1652 : // variable = '' (the empty string)
1653 : // in their input file. This could happen if e.g. something goes
1654 : // wrong with dollar bracket expression expansion.
1655 66323 : if (vec.empty())
1656 8 : mooseError("Error constructing object '",
1657 : moose_object_with_var_param_name,
1658 : "' while retrieving value for '",
1659 : var_param_name,
1660 : "' parameter! Did you forget to set '",
1661 : var_param_name,
1662 : "' or set it to '' (empty string) by accident?");
1663 :
1664 : // When using vector variables, we are only going to use the first one in the list at the
1665 : // interface level...
1666 66315 : variable_name = vec[0];
1667 66315 : }
1668 :
1669 544614 : return variable_name;
1670 0 : }
1671 :
1672 : void
1673 3403937 : InputParameters::renameParamInternal(const std::string & old_name,
1674 : const std::string & new_name,
1675 : const std::string & docstring,
1676 : const std::string & removal_date)
1677 : {
1678 3403937 : auto params_it = _params.find(old_name);
1679 3403937 : if (params_it == _params.end())
1680 0 : mooseError("Requested to rename parameter '",
1681 : old_name,
1682 : "' but that parameter name doesn't exist in the parameters object.");
1683 : mooseAssert(params_it->second._deprecation_message.empty(),
1684 : "Attempting to rename the parameter, '" << old_name << "', that is deprecated");
1685 :
1686 3403937 : auto new_metadata = std::move(params_it->second);
1687 3403937 : if (!docstring.empty())
1688 380644 : new_metadata._doc_string = docstring;
1689 3403937 : _params.emplace(new_name, std::move(new_metadata));
1690 3403937 : _params.erase(params_it);
1691 :
1692 3403937 : auto values_it = _values.find(old_name);
1693 3403937 : auto new_value = std::move(values_it->second);
1694 3403937 : _values.emplace(new_name, std::move(new_value));
1695 3403937 : _values.erase(values_it);
1696 :
1697 3403937 : std::string deprecation_message;
1698 3403937 : if (!removal_date.empty())
1699 5975066 : deprecation_message = "'" + old_name + "' has been deprecated and will be removed on " +
1700 5975066 : removal_date + ". Please use '" + new_name + "' instead.";
1701 :
1702 3403937 : _old_to_new_name_and_dep.emplace(old_name, std::make_pair(new_name, deprecation_message));
1703 3403937 : _new_to_old_names.emplace(new_name, old_name);
1704 3403937 : }
1705 :
1706 : void
1707 397243 : InputParameters::renameCoupledVarInternal(const std::string & old_name,
1708 : const std::string & new_name,
1709 : const std::string & docstring,
1710 : const std::string & removal_date)
1711 : {
1712 397243 : auto coupled_vars_it = _coupled_vars.find(old_name);
1713 397243 : if (coupled_vars_it == _coupled_vars.end())
1714 0 : mooseError("Requested to rename coupled variable '",
1715 : old_name,
1716 : "' but that coupled variable name doesn't exist in the parameters object.");
1717 :
1718 397243 : _coupled_vars.insert(new_name);
1719 397243 : _coupled_vars.erase(coupled_vars_it);
1720 :
1721 397243 : renameParamInternal(old_name, new_name, docstring, removal_date);
1722 397243 : }
1723 :
1724 : void
1725 258492 : InputParameters::renameParam(const std::string & old_name,
1726 : const std::string & new_name,
1727 : const std::string & new_docstring)
1728 : {
1729 258492 : renameParamInternal(old_name, new_name, new_docstring, "");
1730 258492 : }
1731 :
1732 : void
1733 157912 : InputParameters::renameCoupledVar(const std::string & old_name,
1734 : const std::string & new_name,
1735 : const std::string & new_docstring)
1736 : {
1737 157912 : renameCoupledVarInternal(old_name, new_name, new_docstring, "");
1738 157912 : }
1739 :
1740 : void
1741 2748202 : InputParameters::deprecateParam(const std::string & old_name,
1742 : const std::string & new_name,
1743 : const std::string & removal_date)
1744 : {
1745 2748202 : renameParamInternal(old_name, new_name, "", removal_date);
1746 2748202 : }
1747 :
1748 : void
1749 239331 : InputParameters::deprecateCoupledVar(const std::string & old_name,
1750 : const std::string & new_name,
1751 : const std::string & removal_date)
1752 : {
1753 239331 : renameCoupledVarInternal(old_name, new_name, "", removal_date);
1754 239331 : }
1755 :
1756 : std::string
1757 9053840530 : InputParameters::checkForRename(const std::string & name) const
1758 : {
1759 9053840530 : if (auto it = _old_to_new_name_and_dep.find(name); it != _old_to_new_name_and_dep.end())
1760 332928 : return it->second.first;
1761 : else
1762 9053507602 : return name;
1763 : }
1764 :
1765 : std::vector<std::string>
1766 64450766 : InputParameters::paramAliases(const std::string & param_name) const
1767 : {
1768 : mooseAssert(_values.find(param_name) != _values.end(),
1769 : "The parameter we are searching for aliases for should exist in our parameter map");
1770 193352298 : std::vector<std::string> aliases = {param_name};
1771 :
1772 64644075 : for (const auto & pr : as_range(_new_to_old_names.equal_range(param_name)))
1773 193309 : aliases.push_back(pr.second);
1774 :
1775 64450766 : return aliases;
1776 64450766 : }
1777 :
1778 : std::optional<Moose::DataFileUtils::Path>
1779 12484 : InputParameters::queryDataFileNamePath(const std::string & name) const
1780 : {
1781 12484 : return at(checkForRename(name))._data_file_name_path;
1782 : }
1783 :
1784 : std::pair<std::string, const hit::Node *>
1785 3512 : InputParameters::paramMessageContext(const std::string & param) const
1786 : {
1787 3512 : const hit::Node * node = nullptr;
1788 :
1789 3512 : std::string fullpath;
1790 : // First try to find the parameter
1791 3512 : if (const hit::Node * param_node = getHitNode(param))
1792 : {
1793 3334 : fullpath = param_node->fullpath();
1794 3334 : node = param_node;
1795 : }
1796 : // If no parameter node, hope for a block node
1797 178 : else if (const hit::Node * block_node = getHitNode())
1798 : {
1799 172 : node = block_node;
1800 172 : fullpath = block_node->fullpath() + "/" + param;
1801 : }
1802 : // Didn't find anything, at least use the parameter
1803 : else
1804 6 : fullpath = param;
1805 :
1806 7024 : return {fullpath + ": ", node};
1807 3512 : }
1808 :
1809 : std::string
1810 1923 : InputParameters::paramMessagePrefix(const std::string & param) const
1811 : {
1812 1923 : auto [prefix, node] = paramMessageContext(param);
1813 1923 : if (node)
1814 1923 : prefix = Moose::hitMessagePrefix(*node) + prefix;
1815 3846 : return prefix;
1816 1923 : }
1817 :
1818 : [[noreturn]] void
1819 1661 : InputParameters::callMooseError(std::string msg,
1820 : const bool with_prefix /* = true */,
1821 : const hit::Node * node /* = nullptr */) const
1822 : {
1823 : // Find the context of the app if we can. This will let our errors be
1824 : // prefixed by the multiapp name (if applicable) and will flush the
1825 : // console before outputting an error
1826 1661 : MooseApp * app = nullptr;
1827 1661 : if (isMooseBaseObject() && have_parameter<MooseApp *>(MooseBase::app_param))
1828 1617 : app = get<MooseApp *>(MooseBase::app_param);
1829 :
1830 1661 : MooseBase::callMooseError(app, *this, msg, with_prefix, node);
1831 : }
|