https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InputParameters.C
Go to the documentation of this file.
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
32{
33 InputParameters params;
34 return params;
35}
36
38 : Parameters(),
39 _collapse_nesting(false),
40 _moose_object_syntax_visibility(true),
41 _show_deprecated_message(true),
42 _allow_copy(true),
43 _hit_node(nullptr),
44 _finalized(false)
45{
46}
47
49 : Parameters(), _show_deprecated_message(true), _allow_copy(true)
50{
51 *this = rhs;
52}
53
54InputParameters::InputParameters(const Parameters & rhs)
55 : _show_deprecated_message(true), _allow_copy(true)
56{
57 _params.clear();
58 Parameters::operator=(rhs);
59 _collapse_nesting = false;
61}
62
63void
65{
66 Parameters::clear();
67 _params.clear();
68 _coupled_vars.clear();
70 _collapse_nesting = false;
73 _allow_copy = true;
75 _new_to_old_names.clear();
76 _hit_node = nullptr;
77 _finalized = false;
78}
79
80void
81InputParameters::addClassDescription(const std::string & doc_string)
82{
83 _class_description = doc_string;
84}
85
86void
87InputParameters::set_attributes(const std::string & name_in, bool inserted_only)
88{
89 const auto & name = checkForRename(name_in);
90
91 if (!inserted_only)
92 {
93 auto & metadata = _params[name];
100 metadata._set_by_add_param = false;
101
102 // valid_params don't make sense for MooseEnums
103 if (!have_parameter<MooseEnum>(name) && !have_parameter<MultiMooseEnum>(name))
104 metadata._valid = true;
105 }
106}
107
108std::optional<std::string>
109InputParameters::queryDeprecatedParamMessage(const std::string & name_in) const
110{
111 const auto & name = checkForRename(name_in);
113 {
114 auto deprecation_message = [this](const auto & name, const auto & message) -> std::string
115 { return paramMessagePrefix(name) + message; };
116
117 if (_params.count(name) && !libmesh_map_find(_params, name)._deprecation_message.empty())
118 return deprecation_message(name,
119 "The parameter '" + name + "' is deprecated.\n" +
120 libmesh_map_find(_params, name)._deprecation_message);
121 else if (auto it = _old_to_new_name_and_dep.find(name_in);
122 it != _old_to_new_name_and_dep.end() && !it->second.second.empty())
123 return deprecation_message(name_in, it->second.second);
124 }
125 return {};
126}
127
128std::string
133
136{
137 // An error to help minimize the segmentation faults that occure when MooseObjects do not have the
138 // correct constructor
139 if (!rhs._allow_copy)
140 {
141 // If _allow_parameter_copy is set, these should be too (see
142 // InputParameterWarehouse::addInputParameters)
143 const std::string & name = rhs.getObjectName();
144 const std::string & type = rhs.getObjectType(); // could be empty
145 const std::string name_example = type.size() ? type : "the " + name + " object";
146 const std::string type_example = type.size() ? type : "MyObject";
148 "Copying of the InputParameters object for ",
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 }
159
160 Parameters::operator=(rhs);
161
162 _params = rhs._params;
163
173 _hit_node = rhs._hit_node;
174 _finalized = false;
175
176 return *this;
177}
178
181{
182 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 for (auto it = rhs._params.begin(); it != rhs._params.end(); ++it)
187 _params[it->first] = it->second;
188
189 _buildable_types.insert(
190 _buildable_types.end(), rhs._buildable_types.begin(), rhs._buildable_types.end());
191 _buildable_rm_types.insert(
192 _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 _coupled_vars.insert(rhs._coupled_vars.begin(), rhs._coupled_vars.end());
198
200 rhs._old_to_new_name_and_dep.end());
201 _new_to_old_names.insert(rhs._new_to_old_names.begin(), rhs._new_to_old_names.end());
202 return *this;
203}
204
205void
207 const std::string & doc_string)
208{
209 auto coupled_vars_it = _new_to_deprecated_coupled_vars.find(new_name);
210 if (coupled_vars_it != _new_to_deprecated_coupled_vars.end())
211 {
212 auto params_it = _params.find(coupled_vars_it->second);
213 if (params_it == _params.end())
214 mooseError("There must have been a mistake in the construction of the new to deprecated "
215 "coupled vars map because the old name ",
216 coupled_vars_it->second,
217 " doesn't exist in the parameters data.");
218
219 params_it->second._doc_string = doc_string;
220 }
221}
222
223void
224InputParameters::addCoupledVar(const std::string & name, Real value, const std::string & doc_string)
225{
226 addParam<std::vector<VariableName>>(name, doc_string);
227 _coupled_vars.insert(name);
228 auto & metadata = _params[name];
229 metadata._coupled_default.assign(1, value);
230 metadata._have_coupled_default = true;
231
232 // Set the doc string for any associated deprecated coupled var
233 setDeprecatedVarDocString(name, doc_string);
234}
235
236void
237InputParameters::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 addParam<std::vector<VariableName>>(name, doc_string);
243 _coupled_vars.insert(name);
244 auto & metadata = _params[name];
245 metadata._coupled_default = value;
246 metadata._have_coupled_default = true;
247
248 // Set the doc string for any associated deprecated coupled var
249 setDeprecatedVarDocString(name, doc_string);
250}
251
252void
253InputParameters::addCoupledVar(const std::string & name, const std::string & doc_string)
254{
255 addParam<std::vector<VariableName>>(name, doc_string);
256 _coupled_vars.insert(name);
257
258 // Set the doc string for any associated deprecated coupled var
259 setDeprecatedVarDocString(name, doc_string);
260}
261
262void
263InputParameters::addDeprecatedCoupledVar(const std::string & old_name,
264 const std::string & new_name,
265 const std::string & removal_date /*=""*/)
266{
267 mooseDeprecated("Please use 'deprecateCoupledVar'");
268
270
271 // Set the doc string if we are adding the deprecated var after the new var has already been added
272 auto params_it = _params.find(new_name);
273 std::string doc_string;
274 if (params_it != _params.end())
275 doc_string = params_it->second._doc_string;
276
277 addParam<std::vector<VariableName>>(old_name, doc_string);
278 _coupled_vars.insert(old_name);
279 _new_to_deprecated_coupled_vars.emplace(new_name, old_name);
280
281 std::string deprecation_message =
282 "The coupled variable parameter '" + old_name + "' has been deprecated";
283 if (!removal_date.empty())
284 deprecation_message += " and will be removed " + removal_date;
285 deprecation_message += ". Please use the '" + new_name + "' coupled variable parameter instead.";
286 _params[old_name]._deprecation_message = deprecation_message;
288}
289
290void
292 const std::string & base_name,
293 const std::string & num_name,
294 const std::string & doc_string)
295{
296 addParam<std::vector<VariableName>>(name, doc_string);
297 _coupled_vars.insert(name);
298 _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 addParam<std::string>(base_name, doc_string + " (base_name)");
302 addParam<unsigned int>(num_name, doc_string + " (num_name)");
303}
304
305void
307 const std::string & base_name,
308 const std::string & num_name,
309 const std::string & doc_string)
310{
311 addRequiredParam<std::vector<VariableName>>(name, doc_string);
312
313 addCoupledVarWithAutoBuild(name, base_name, num_name, doc_string);
314}
315
316void
317InputParameters::addRequiredCoupledVar(const std::string & name, const std::string & doc_string)
318{
319 addRequiredParam<std::vector<VariableName>>(name, doc_string);
320 _coupled_vars.insert(name);
321}
322
323std::string
324InputParameters::getDocString(const std::string & name_in) const
325{
326 const auto & name = checkForRename(name_in);
327
328 std::string doc_string;
329 auto it = _params.find(name);
330 if (it != _params.end())
331 for (const auto & ch : it->second._doc_string)
332 {
333 if (ch == '\n')
334 doc_string += " ... ";
335 else
336 doc_string += ch;
337 }
338
339 return doc_string;
340}
341
342void
343InputParameters::setDocString(const std::string & name_in, const std::string & doc)
344{
345 const auto & name = checkForRename(name_in);
346
347 auto it = _params.find(name);
348 if (it == _params.end())
349 mooseError("Unable to set the documentation string (using setDocString) for the \"",
350 name,
351 "\" parameter, the parameter does not exist.");
352 it->second._doc_string = doc;
353}
354
355std::string
356InputParameters::getDocUnit(const std::string & name_in) const
357{
358 const auto & name = checkForRename(name_in);
359 return _params.at(name)._doc_unit;
360}
361
362void
363InputParameters::setDocUnit(const std::string & name_in, const std::string & doc_unit)
364{
365 const auto & name = checkForRename(name_in);
366 _params[name]._doc_unit = doc_unit;
367}
368
369bool
370InputParameters::isParamRequired(const std::string & name_in) const
371{
372 const auto & name = checkForRename(name_in);
373 return _params.count(name) > 0 && _params.at(name)._required;
374}
375
376void
377InputParameters::makeParamNotRequired(const std::string & name_in)
378{
379 const auto & name = checkForRename(name_in);
380
381 if (_params.count(name))
382 _params[name]._required = false;
383}
384
385bool
386InputParameters::isParamValid(const std::string & name_in) const
387{
388 const auto & name = checkForRename(name_in);
389 if (have_parameter<MooseEnum>(name))
390 return get<MooseEnum>(name).isValid();
391 else if (have_parameter<std::vector<MooseEnum>>(name))
392 {
393 for (auto it = get<std::vector<MooseEnum>>(name).begin();
394 it != get<std::vector<MooseEnum>>(name).end();
395 ++it)
396 if (!it->isValid())
397 return false;
398 return true;
399 }
400 else if (have_parameter<MultiMooseEnum>(name))
401 return get<MultiMooseEnum>(name).isValid();
402 else if (have_parameter<std::vector<MultiMooseEnum>>(name))
403 {
404 for (auto it = get<std::vector<MultiMooseEnum>>(name).begin();
405 it != get<std::vector<MultiMooseEnum>>(name).end();
406 ++it)
407 if (!it->isValid())
408 return false;
409 return true;
410 }
411 else if (have_parameter<ExecFlagEnum>(name))
412 return get<ExecFlagEnum>(name).isValid();
413 else
414 return _params.count(name) > 0 && _params.at(name)._valid;
415}
416
417bool
418InputParameters::isParamSetByAddParam(const std::string & name_in) const
419{
420 const auto & name = checkForRename(name_in);
421 return _params.count(name) > 0 && _params.at(name)._set_by_add_param;
422}
423
424bool
425InputParameters::isParamDeprecated(const std::string & name_in) const
426{
427 const auto & name = checkForRename(name_in);
428 return _params.count(name) > 0 && !_params.at(name)._deprecation_message.empty();
429}
430
431#ifdef MOOSE_KOKKOS_ENABLED
432bool
437#endif
438
439bool
441{
442 for (const auto & it : *this)
443 if (isParamRequired(it.first) && !isParamValid(it.first))
444 return false;
445 return true;
446}
447
448bool
449InputParameters::isPrivate(const std::string & name_in) const
450{
451 const auto & name = checkForRename(name_in);
452 return _params.count(name) > 0 && _params.at(name)._is_private;
453}
454
455void
456InputParameters::declareControllable(const std::string & input_names,
457 std::set<ExecFlagType> execute_flags)
458{
459 std::vector<std::string> names;
460 MooseUtils::tokenize<std::string>(input_names, names, 1, " ");
461 for (auto & name_in : names)
462 {
463 const auto & name = checkForRename(name_in);
464 auto map_iter = _params.find(name);
465 if (map_iter != _params.end()) // error is handled by checkParams method
466 {
467 map_iter->second._controllable = true;
468 map_iter->second._controllable_flags = execute_flags;
469 }
470 else
471 mooseError("The input parameter '",
472 name,
473 "' does not exist, thus cannot be marked as controllable.");
474 }
475}
476
477bool
478InputParameters::isControllable(const std::string & name_in) const
479{
480 const auto & name = checkForRename(name_in);
481 return _params.count(name) > 0 && _params.at(name)._controllable;
482}
483
484const std::set<ExecFlagType> &
485InputParameters::getControllableExecuteOnTypes(const std::string & name_in) const
486{
487 const auto & name = checkForRename(name_in);
488 return at(name)._controllable_flags;
489}
490
491void
492InputParameters::registerBase(const std::string & value)
493{
494 InputParameters::set<std::string>(MooseBase::moose_base_param) = value;
495 _params[MooseBase::moose_base_param]._is_private = true;
496}
497
498bool
500{
501 return have_parameter<std::string>(MooseBase::moose_base_param);
502}
503
504const std::string &
506{
507 if (!have_parameter<std::string>(MooseBase::moose_base_param))
508 mooseError("InputParameters::getBase(): Parameters do not have base; one needs to be set with "
509 "registerBase()");
510 return get<std::string>(MooseBase::moose_base_param);
511}
512
513void
515{
516 InputParameters::set<std::string>("_moose_warehouse_system_name") = value;
517 _params["_moose_warehouse_system_name"]._is_private = true;
518}
519
520const std::string &
522{
523 mooseAssert(have_parameter<std::string>("_moose_warehouse_system_name"),
524 "SystemAttributeName is not available! Call 'registerSystemAttributeName' (usually "
525 "in the validParams function) before you try accessing it!");
526 return Parameters::get<std::string>("_moose_warehouse_system_name");
527}
528
529void
531{
532 _buildable_types.clear();
533 MooseUtils::tokenize(names, _buildable_types, 1, " \t\n\v\f\r"); // tokenize on whitespace
534}
535
536void
538 const std::string & name,
541{
542 _buildable_rm_types.emplace_back(name, rm_type, input_parameter_callback);
543}
544
545const std::vector<std::string> &
550
551const std::vector<std::tuple<std::string,
558
559void
561{
562 _collapse_nesting = collapse;
563}
564
565bool
570
571void
576
577bool
582
583#define checkMooseType(param_type, name) \
584 if (have_parameter<param_type>(name) || have_parameter<std::vector<param_type>>(name)) \
585 error = "non-controllable type '" + type(name) + "' for parameter '" + \
586 paramFullpath(param_name) + "' marked controllable";
587
588void
589InputParameters::checkParams(const std::string & parsing_syntax)
590{
591 const std::string parampath = blockFullpath() != "" ? blockFullpath() : parsing_syntax;
592
593 // Required parameters
594 const auto required_param_errors = missingRequiredParamErrors(parsing_syntax);
595
596 if (required_param_errors.size())
597 mooseError(MooseUtils::stringJoin(required_param_errors, "\n"));
598
599 // Range checked parameters
600 for (const auto & [name, param_ptr] : *this)
601 {
602 if (const auto error = parameterRangeCheck(*param_ptr, parampath + "/" + name, name, false))
603 {
604 if (error->first)
605 paramError(name, error->second);
606 else
607 mooseError("For range checked parameter '" + name + "': " + error->second);
608 }
609 }
610
611 // Controllable parameters
612 for (const auto & param_name : getControllableParameters())
613 {
614 if (isPrivate(param_name))
615 paramError(param_name,
616 "private parameter '" + paramFullpath(param_name) + "' marked controllable");
617
618 std::optional<std::string> error;
619 checkMooseType(NonlinearVariableName, param_name);
620 checkMooseType(AuxVariableName, param_name);
621 checkMooseType(VariableName, param_name);
622 checkMooseType(BoundaryName, param_name);
623 checkMooseType(SubdomainName, param_name);
624 checkMooseType(PostprocessorName, param_name);
625 checkMooseType(VectorPostprocessorName, param_name);
626 checkMooseType(UserObjectName, param_name);
627 checkMooseType(MaterialPropertyName, param_name);
628 if (error)
629 paramError(param_name, *error);
630 }
631}
632
633std::vector<std::string>
634InputParameters::missingRequiredParamErrors(const std::string & parsing_syntax,
635 const std::set<std::string> & skip_required_params,
636 bool skip_private) const
637{
638 const std::string parampath = blockFullpath() != "" ? blockFullpath() : parsing_syntax;
639
640 // Required parameters
641 std::vector<std::string> required_param_errors;
642 for (const auto & it : *this)
643 {
644 const auto param_name = checkForRename(it.first);
645 if (skip_required_params.count(param_name) || (skip_private && isPrivate(param_name)))
646 continue;
647
648 if (!isParamValid(param_name) && isParamRequired(param_name))
649 {
650 // check if an old, deprecated name exists for this parameter that may be specified
651 auto oit = _new_to_deprecated_coupled_vars.find(param_name);
652 if (oit != _new_to_deprecated_coupled_vars.end() && isParamValid(oit->second))
653 continue;
654
655 required_param_errors.push_back("missing required parameter '" + parampath + "/" +
656 param_name + "'\n\tDoc String: \"" +
657 getDocString(param_name) + "\"");
658 }
659 }
660
661 return required_param_errors;
662}
663
664std::optional<std::pair<bool, std::string>>
665InputParameters::parameterRangeCheck(const Parameters::Value & value,
666 const std::string & long_name,
667 const std::string & short_name,
668 const bool include_param_path)
669{
670#define dynamicCastRangeCheck(type, up_type, long_name, short_name) \
671 do \
672 { \
673 if (const auto scalar_p = dynamic_cast<const InputParameters::Parameter<type> *>(&value)) \
674 return rangeCheck<type, up_type>(long_name, short_name, *scalar_p, include_param_path); \
675 if (const auto vector_p = \
676 dynamic_cast<const InputParameters::Parameter<std::vector<type>> *>(&value)) \
677 return rangeCheck<type, up_type>(long_name, short_name, *vector_p, include_param_path); \
678 } while (0)
679
680 dynamicCastRangeCheck(Real, Real, long_name, short_name);
681 dynamicCastRangeCheck(int, long, long_name, short_name);
682 dynamicCastRangeCheck(long, long, long_name, short_name);
683 dynamicCastRangeCheck(unsigned int, long, long_name, short_name);
684#undef dynamicCastRangeCheck
685
686 return {};
687}
688
689void
690InputParameters::finalize(const std::string & parsing_syntax)
691{
692 mooseAssert(!isFinalized(), "Already finalized");
693
694 checkParams(parsing_syntax);
695
696 // Set parameters that represent file types
697 for (const auto & name_value : *this)
698 {
699 const auto & param_name = name_value.first;
700 const auto & param_value = name_value.second;
701
702 // Helper for setting a file typed parameter value
703 const auto set_filename = [&](auto & value)
704 {
705 constexpr bool is_data_file_name =
706 std::is_same_v<std::decay_t<decltype(value)>, DataFileName>;
707
708 // We have behavior (which is gross) that requires that for
709 // everything but DataFileName, if the value is empty we
710 // don't bother looking for it
711 if constexpr (!is_data_file_name)
712 {
713 if (value.empty())
714 return;
715 }
716
717 // Setup options for searching for the path
719 // Associate relative path searches with the folder
720 // that input file that has this parameter is located
721 options.base = getFileBase(param_name);
722 // If we don't explicitly have a DataFileName parameter,
723 // we only want to augment cases where a data name is
724 // explicitly set (like moose:file). We don't want to
725 // search all other data. To presere previous behavior,
726 // we also don't want to error if nothing is found; for
727 // example if a relative or absolute path is not found.
728 // The only time we'll error is if the data name is
729 // explicitly set and the path doesn't exist in the data
730 // or if that data name isn't registered.
731 if constexpr (!is_data_file_name)
732 {
733 options.search_all_data = false;
734 options.graceful = true;
735 }
736
738 try
739 {
740 Moose::ScopedThrowOnError scoped_throw_on_error;
741 path = Moose::DataFileUtils::getPath(value, options);
742 }
743 catch (std::exception & e)
744 {
745 paramError(param_name, e.what());
746 }
747
748 value = path.path;
749 at(param_name)._data_file_name_path = path;
750 };
751
752#define set_if_filename(type) \
753 else if (auto type_value = dynamic_cast<Parameters::Parameter<type> *>(param_value.get())) \
754 set_filename(type_value->set()); \
755 else if (auto type_values = dynamic_cast<Parameters::Parameter<std::vector<type>> *>( \
756 param_value.get())) for (auto & value : type_values->set()) set_filename(value)
757
758 if (false)
759 ;
760 set_if_filename(FileName);
761 set_if_filename(FileNameNoExtension);
762 set_if_filename(MeshFileName);
763 set_if_filename(MatrixFileName);
764 set_if_filename(DataFileName);
765#undef set_if_filename
766 }
767
768 _finalized = true;
769}
770
771std::filesystem::path
772InputParameters::getFileBase(const std::optional<std::string> & param_name) const
773{
774 mooseAssert(!have_parameter<std::string>("_app_name"),
775 "Not currently setup to work with app FileName parameters");
776
777 const hit::Node * hit_node = nullptr;
778
779 // Context from the individual parameter
780 if (param_name)
781 hit_node = getHitNode(*param_name);
782 // Context from the parameters
783 if (!hit_node)
784 hit_node = getHitNode();
785 // No hit node, so use the cwd (no input files)
786 if (!hit_node)
787 return std::filesystem::current_path();
788
789 // Find any context that isn't command line arguments
790 while (hit_node && hit_node->filename() == "CLI_ARGS")
791 hit_node = hit_node->parent();
792
793 // Failed to find a node up the tree that isn't a command line argument
794 if (!hit_node)
795 {
796 const std::string error = "Input context was set via a command-line argument and does not have "
797 "sufficient context for determining a file path.";
798 if (param_name)
799 paramError(*param_name, error);
800 else
801 mooseError(error);
802 }
803
804 return std::filesystem::absolute(std::filesystem::path(hit_node->filename()).parent_path());
805}
806
807bool
808InputParameters::isRangeChecked(const std::string & param_name) const
809{
810 const auto & name = checkForRename(param_name);
811 return !_params.find(name)->second._range_function.empty();
812}
813
814std::string
815InputParameters::rangeCheckedFunction(const std::string & param_name) const
816{
817 const auto & name = checkForRename(param_name);
818 return _params.at(name)._range_function;
819}
820
821bool
822InputParameters::hasDefault(const std::string & param_name) const
823{
824 const auto & name = checkForRename(param_name);
825 if (hasDefaultCoupledValue(name))
826 return true;
827 // If it has a default, it's already valid
828 else if (isParamSetByAddParam(name))
829 return true;
830 else if (isParamValid(name))
831 mooseError("No way to know if the parameter '", param_name, "' has a default");
832 else
833 return false;
834}
835
836bool
837InputParameters::hasCoupledVar(const std::string & coupling_name) const
838{
839 return _coupled_vars.find(coupling_name) != _coupled_vars.end();
840}
841
842void
843InputParameters::setCoupledVar(const std::string & coupling_name, const std::string & value)
844{
845 setCoupledVar(coupling_name, std::vector<VariableName>{value});
846}
847
848void
849InputParameters::setCoupledVar(const std::string & coupling_name,
850 const std::vector<VariableName> & values)
851{
852 const auto & actual_name = checkForRename(coupling_name);
853
854 if (!hasCoupledVar(actual_name))
855 mooseError("Unable to set coupled variable parameter '",
856 coupling_name,
857 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
858
859 set<std::vector<VariableName>>(actual_name) = values;
860}
861
862const std::vector<VariableName> &
863InputParameters::getCoupledVar(const std::string & coupling_name) const
864{
865 const auto & actual_name = checkForRename(coupling_name);
866
867 if (!hasCoupledVar(actual_name))
868 mooseError("Unable to get coupled variable parameter '",
869 coupling_name,
870 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
871
872 return get<std::vector<VariableName>>(actual_name);
873}
874
875bool
876InputParameters::hasDefaultCoupledValue(const std::string & coupling_name) const
877{
878 return _params.count(coupling_name) > 0 && _params.at(coupling_name)._have_coupled_default &&
879 _coupled_vars.count(coupling_name) > 0;
880}
881
882void
883InputParameters::defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i)
884{
885 const auto & actual_name = checkForRename(coupling_name);
886 _params[actual_name]._coupled_default.resize(i + 1);
887 _params[actual_name]._coupled_default[i] = value;
888 _params[actual_name]._have_coupled_default = true;
889}
890
891Real
892InputParameters::defaultCoupledValue(const std::string & coupling_name, unsigned int i) const
893{
894 auto value_it = _params.find(coupling_name);
895
896 if (value_it == _params.end() || !value_it->second._have_coupled_default)
897 mooseError("Attempted to retrieve default value for coupled variable '",
898 coupling_name,
899 "' when none was provided. \n\nThere are three reasons why this may have "
900 "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
901 "to provide a default value. \n 2. This should have been a required coupled "
902 "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
903 "coupled value should have been properly guarded with isCoupled()\n");
904
905 return value_it->second._coupled_default.at(i);
906}
907
908unsigned int
909InputParameters::numberDefaultCoupledValues(const std::string & coupling_name) const
910{
911 auto value_it = _params.find(coupling_name);
912 if (value_it == _params.end())
913 mooseError("Attempted to retrieve default value for coupled variable '",
914 coupling_name,
915 "' when none was provided.");
916 return value_it->second._coupled_default.size();
917}
918
919std::map<std::string, std::pair<std::string, std::string>>
921{
922 std::map<std::string, std::pair<std::string, std::string>> abv;
923 for (auto it = _params.begin(); it != _params.end(); ++it)
924 {
925 if (!it->second._autobuild_vecs.first.empty())
926 abv[it->first] = it->second._autobuild_vecs;
927 }
928 return abv;
929}
930
931std::string
932InputParameters::type(const std::string & name_in) const
933{
934 const auto & name = checkForRename(name_in);
935 if (!_values.count(name))
936 mooseError("Parameter \"", name, "\" not found.\n\n", *this);
937
938 if (_coupled_vars.find(name) != _coupled_vars.end())
939 return "std::vector<VariableName>";
940 else if (_params.count(name) > 0 && !_params.at(name)._custom_type.empty())
941 return _params.at(name)._custom_type;
942 return _values.at(name)->type();
943}
944
945std::string
946InputParameters::getMooseType(const std::string & name_in) const
947{
948 const auto & name = checkForRename(name_in);
949 std::string var;
950
951 if (have_parameter<VariableName>(name))
952 var = get<VariableName>(name);
953 else if (have_parameter<NonlinearVariableName>(name))
954 var = get<NonlinearVariableName>(name);
955 else if (have_parameter<LinearVariableName>(name))
956 var = get<LinearVariableName>(name);
957 else if (have_parameter<AuxVariableName>(name))
958 var = get<AuxVariableName>(name);
959 else if (have_parameter<PostprocessorName>(name))
960 var = get<PostprocessorName>(name);
961 else if (have_parameter<VectorPostprocessorName>(name))
962 var = get<VectorPostprocessorName>(name);
963 else if (have_parameter<FunctionName>(name))
964 var = get<FunctionName>(name);
965 else if (have_parameter<UserObjectName>(name))
966 var = get<UserObjectName>(name);
967 else if (have_parameter<MaterialPropertyName>(name))
968 var = get<MaterialPropertyName>(name);
969 else if (have_parameter<std::string>(name))
970 var = get<std::string>(name);
971
972 return var;
973}
974
975std::vector<std::string>
976InputParameters::getVecMooseType(const std::string & name_in) const
977{
978 const auto & name = checkForRename(name_in);
979 std::vector<std::string> svars;
980
981 if (have_parameter<std::vector<VariableName>>(name))
982 {
983 std::vector<VariableName> vars = get<std::vector<VariableName>>(name);
984 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
985 }
986 else if (have_parameter<std::vector<NonlinearVariableName>>(name))
987 {
988 std::vector<NonlinearVariableName> vars = get<std::vector<NonlinearVariableName>>(name);
989 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
990 }
991 else if (have_parameter<std::vector<AuxVariableName>>(name))
992 {
993 std::vector<AuxVariableName> vars = get<std::vector<AuxVariableName>>(name);
994 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
995 }
996 else if (have_parameter<std::vector<MaterialPropertyName>>(name))
997 {
998 std::vector<MaterialPropertyName> vars = get<std::vector<MaterialPropertyName>>(name);
999 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
1000 }
1001 else if (have_parameter<std::vector<std::string>>(name))
1002 {
1003 std::vector<std::string> vars = get<std::vector<std::string>>(name);
1004 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
1005 }
1006
1007 return svars;
1008}
1009
1010bool
1012{
1013 return have_parameter<std::string>(MooseBase::type_param) &&
1014 get<std::string>(MooseBase::type_param).size() &&
1015 have_parameter<std::string>(MooseBase::name_param);
1016}
1017
1018const std::string *
1020{
1021 return have_parameter<std::string>(MooseBase::type_param)
1022 ? &get<std::string>(MooseBase::type_param)
1023 : nullptr;
1024}
1025
1026const std::string &
1028{
1029 if (const auto type_ptr = queryObjectType())
1030 return *type_ptr;
1031 ::mooseError("InputParameters::getObjectType(): Missing '", MooseBase::type_param, "' param");
1032}
1033
1034const std::string &
1036{
1037 if (!have_parameter<std::string>(MooseBase::name_param))
1038 ::mooseError("InputParameters::getObjectName(): Missing '", MooseBase::name_param, "' param");
1039 return get<std::string>(MooseBase::name_param);
1040}
1041
1042void
1043InputParameters::addParamNamesToGroup(const std::string & space_delim_names,
1044 const std::string group_name)
1045{
1046 std::vector<std::string> elements;
1047 MooseUtils::tokenize(space_delim_names, elements, 1, " \t\n\v\f\r"); // tokenize on whitespace
1048
1049 // Since we don't require types (templates) for this method, we need
1050 // to get a raw list of parameter names to compare against.
1051 std::set<std::string> param_names;
1052 for (const auto & it : *this)
1053 param_names.insert(it.first);
1054
1055 for (const auto & param_name : elements)
1056 if (_params.count(param_name) > 0)
1057 {
1058 std::string & group = _params[param_name]._group;
1059 if (!group.empty() && group == group_name)
1060 mooseError(
1061 "The parameter '", param_name, "' has already been added to the group '", group, "'.");
1062 group = group_name;
1063 }
1064 else
1065 mooseError("Unable to find a parameter with name: ",
1066 param_name,
1067 " when adding to group ",
1068 group_name,
1069 '.');
1070}
1071
1072void
1073InputParameters::moveParamToGroup(const std::string & name, const std::string & group_name)
1074{
1075 if (_params.count(name) == 0)
1076 mooseError(
1077 "Unable to find a parameter with name: ", name, " when moving to group ", group_name, '.');
1078 _params[name]._group = group_name;
1079}
1080
1081void
1082InputParameters::renameParameterGroup(const std::string & old_name, const std::string & new_name)
1083{
1084 for (auto & param : _params)
1085 if (param.second._group == old_name)
1086 param.second._group = new_name;
1087}
1088
1089void
1091{
1092 auto & cl_data = at(checkForRename(name))._cl_data;
1093 if (!cl_data)
1094 mooseError("InputParameters::setGlobalCommandLineParam: The parameter '",
1095 name,
1096 "' is not a command line parameter");
1097 cl_data->global = true;
1098}
1099
1100bool
1101InputParameters::isCommandLineParameter(const std::string & name) const
1102{
1103 return at(checkForRename(name))._cl_data.has_value();
1104}
1105
1106std::optional<InputParameters::CommandLineMetadata>
1107InputParameters::queryCommandLineMetadata(const std::string & name) const
1108{
1109 const auto & cl_data = at(checkForRename(name))._cl_data;
1110 if (!cl_data)
1111 return {};
1112 return *cl_data;
1113}
1114
1116InputParameters::getCommandLineMetadata(const std::string & name) const
1117{
1118 const auto & cl_data = at(checkForRename(name))._cl_data;
1119 if (!cl_data)
1120 mooseError("InputParameters::getCommandLineMetadata: The parameter '",
1121 name,
1122 "' is not a command line parameter");
1123 return *cl_data;
1124}
1125
1126void
1128{
1129 auto & cl_data = at(checkForRename(name))._cl_data;
1130 if (!cl_data)
1131 mooseError("InputParameters::commandLineParamSet: The parameter '",
1132 name,
1133 "' is not a command line parameter");
1134 cl_data->set_by_command_line = true;
1135}
1136
1137std::string
1138InputParameters::getGroupName(const std::string & param_name_in) const
1139{
1140 const auto & param_name = checkForRename(param_name_in);
1141 auto it = _params.find(param_name);
1142 if (it != _params.end())
1143 return it->second._group;
1144 return std::string();
1145}
1146
1147void
1149 const std::vector<std::string> & exclude,
1150 const bool allow_private)
1151{
1152 // If we're applying all of the things, also associate the top level hit node
1153 if (exclude.empty() && !getHitNode() && common.getHitNode())
1154 setHitNode(*common.getHitNode(), {});
1155
1156 // Loop through the common parameters
1157 for (const auto & it : common)
1158 {
1159 // Common parameter name
1160 const std::string & common_name = it.first;
1161 // Continue to next parameter, if the current is in list of excluded parameters
1162 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1163 continue;
1164
1165 applyParameter(common, common_name, allow_private);
1166 }
1167
1168 // Loop through the coupled variables
1169 for (const auto & var_name : common._coupled_vars)
1170 {
1171 // Continue to next variable, if the current is in list of excluded parameters
1172 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1173 continue;
1174
1175 applyCoupledVar(common, var_name);
1176 }
1177}
1178
1179void
1181 const std::vector<std::string> & exclude,
1182 const bool allow_private)
1183{
1184 for (const auto & it : common)
1185 {
1186 const std::string & common_name = it.first;
1187 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1188 continue;
1189 if (!common.isParamSetByUser(common_name))
1190 continue;
1191 applyParameter(common, common_name, allow_private);
1192 }
1193
1194 for (const auto & var_name : common._coupled_vars)
1195 {
1196 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1197 continue;
1198 if (!common.isParamSetByUser(var_name))
1199 continue;
1200 applyCoupledVar(common, var_name);
1201 }
1202}
1203
1204void
1206 const std::vector<std::string> & include,
1207 bool allow_private)
1208{
1209 // Loop through the common parameters
1210 for (const auto & it : common)
1211 {
1212 // Common parameter name
1213 const std::string & common_name = it.first;
1214
1215 // Continue to next parameter, if the current is not in list of included parameters
1216 if (std::find(include.begin(), include.end(), common_name) == include.end())
1217 continue;
1218
1219 applyParameter(common, common_name, allow_private);
1220 }
1221
1222 // Loop through the coupled variables
1223 for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
1224 it != common.coupledVarsEnd();
1225 ++it)
1226 {
1227 // Variable name
1228 const std::string var_name = *it;
1229
1230 // Continue to next variable, if the current is not in list of included parameters
1231 if (std::find(include.begin(), include.end(), var_name) == include.end())
1232 continue;
1233
1234 applyCoupledVar(common, var_name);
1235 }
1236}
1237
1238void
1239InputParameters::applyCoupledVar(const InputParameters & common, const std::string & var_name)
1240{
1241 // Disable the display of deprecated message when applying common parameters, this avoids a dump
1242 // of messages
1244
1245 // If the local parameters has a coupled variable, populate it with the value from the common
1246 // parameters, if the common parameters has the coupled variable too
1247 if (hasCoupledVar(var_name))
1248 {
1249 if (common.hasDefaultCoupledValue(var_name))
1250 {
1251 // prepare a vector of default coupled values
1252 std::vector<Real> defaults(common.numberDefaultCoupledValues(var_name));
1253 for (unsigned int j = 0; j < common.numberDefaultCoupledValues(var_name); ++j)
1254 defaults[j] = common.defaultCoupledValue(var_name, j);
1255 addCoupledVar(var_name, defaults, common.getDocString(var_name));
1256 }
1257 else if (common.hasCoupledVar(var_name))
1258 addCoupledVar(var_name, common.getDocString(var_name));
1259 }
1260
1261 // Enable deprecated message printing
1263}
1264
1265void
1267 const std::string & common_name,
1268 bool allow_private)
1269{
1270 // Disable the display of deprecated message when applying common parameters, this avoids a dump
1271 // of messages
1273
1274 const auto & local_name = checkForRename(common_name);
1275
1276 // Extract the properties from the local parameter for the current common parameter name
1277 const bool local_exist = _values.find(local_name) != _values.end();
1278 const bool local_set = _params.count(local_name) > 0 && !_params[local_name]._set_by_add_param;
1279 const bool local_priv = allow_private ? false : isPrivate(local_name);
1280 const bool local_valid = isParamValid(local_name);
1281
1282 // Extract the properties from the common parameter
1283 const bool common_exist = common._values.find(common_name) != common._values.end();
1284 const bool common_priv = allow_private ? false : common.isPrivate(common_name);
1285 const bool common_valid = common.isParamValid(common_name);
1286
1287 /* In order to apply a common parameter 4 statements must be satisfied
1288 * (1) A local parameter must exist with the same name as the common parameter
1289 * (2) Common parameter must be valid and exist
1290 * (3) Local parameter must be invalid OR not have been set from its default
1291 * (4) Both cannot be private
1292 */
1293 if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
1294 (!common_priv || !local_priv))
1295 {
1296 remove(local_name);
1297 _values[local_name] = common._values.find(common_name)->second->clone();
1298 set_attributes(local_name, false);
1299 _params[local_name]._set_by_add_param =
1300 libmesh_map_find(common._params, common_name)._set_by_add_param;
1301 // Keep track of where this param came from if we can. This will enable us to
1302 // produce param errors from objects created within an action that link to
1303 // the parameter in the action
1304 at(local_name)._hit_node = common.getHitNode(common_name);
1305 }
1306 else if (!local_exist && !common_exist)
1307 mooseError("InputParameters::applyParameter(): Attempted to apply invalid parameter \"",
1308 common_name,
1309 "\"");
1310
1311 // Enable deprecated message printing
1313}
1314
1316bool
1317InputParameters::paramSetByUser(const std::string & name) const
1318{
1319 mooseDeprecated("paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
1320 return isParamSetByUser(name);
1321}
1322
1323bool
1324InputParameters::isParamSetByUser(const std::string & name_in) const
1325{
1326 const auto & name = checkForRename(name_in);
1327 // Invalid; for sure not set by the user
1328 if (!isParamValid(name))
1329 return false;
1330 // Parameter is not located in the list (called Parameters::set)
1331 if (!_params.count(name))
1332 return false;
1333 // Special case for a command line option, which is a private parameter
1334 if (const auto cl_data = queryCommandLineMetadata(name))
1335 return cl_data->set_by_command_line;
1336 // Not a command line option, not set by addParam and not private
1337 return !_params.at(name)._set_by_add_param && !_params.at(name)._is_private;
1338}
1339
1340bool
1341InputParameters::isParamDefined(const std::string & name_in) const
1342{
1343 const auto & name = checkForRename(name_in);
1344 return _params.count(name) > 0;
1345}
1346
1347const std::string &
1348InputParameters::getDescription(const std::string & name_in) const
1349{
1350 const auto & name = checkForRename(name_in);
1351 auto it = _params.find(name);
1352 if (it == _params.end())
1353 mooseError("No parameter exists with the name ", name);
1354 return it->second._doc_string;
1355}
1356
1357template <>
1358void
1359InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
1360 const MooseEnum & moose_enum,
1361 const std::string & doc_string)
1362{
1363 InputParameters::set<MooseEnum>(name) = moose_enum; // valid parameter is set by set_attributes
1364 auto & metadata = _params[name];
1365 metadata._required = true;
1366 metadata._doc_string = doc_string;
1367}
1368
1369template <>
1370void
1371InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1372 const MultiMooseEnum & moose_enum,
1373 const std::string & doc_string)
1374{
1375 InputParameters::set<MultiMooseEnum>(name) =
1376 moose_enum; // valid parameter is set by set_attributes
1377 auto & metadata = _params[name];
1378 metadata._required = true;
1379 metadata._doc_string = doc_string;
1380}
1381
1382template <>
1383void
1384InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1385 const std::string & name,
1386 const std::vector<MooseEnum> & moose_enums,
1387 const std::string & doc_string)
1388{
1389 InputParameters::set<std::vector<MooseEnum>>(name) =
1390 moose_enums; // valid parameter is set by set_attributes
1391 auto & metadata = _params[name];
1392 metadata._required = true;
1393 metadata._doc_string = doc_string;
1394}
1395
1396template <>
1397void
1398InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
1399 const std::string & name,
1400 const std::vector<MultiMooseEnum> & moose_enums,
1401 const std::string & doc_string)
1402{
1403 mooseAssert(
1404 moose_enums.size() == 1,
1405 "Only 1 MultiMooseEnum is supported in addRequiredParam<std::vector<MultiMooseEnum>> for " +
1406 name);
1407 mooseAssert(!moose_enums[0].items().empty(),
1408 "The MultiMooseEnum in addRequiredParam<std::vector<MultiMooseEnum>> is empty for " +
1409 name);
1410 InputParameters::set<std::vector<MultiMooseEnum>>(name) =
1411 moose_enums; // valid parameter is set by set_attributes
1412 auto & metadata = _params[name];
1413 metadata._required = true;
1414 metadata._doc_string = doc_string;
1415}
1416
1417template <>
1418void
1419InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1420 const std::string & /*doc_string*/)
1421{
1422 mooseError("You must supply a MooseEnum object when using addParam, even if the parameter is not "
1423 "required!");
1424}
1425
1426template <>
1427void
1428InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1429 const std::string & /*doc_string*/)
1430{
1431 mooseError("You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1432 "is not required!");
1433}
1434
1435template <>
1436void
1437InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1438 const std::string & /*doc_string*/)
1439{
1440 mooseError("You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1441 "parameter is not required!");
1442}
1443
1444template <>
1445void
1446InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1447 const std::string & /*doc_string*/)
1448{
1449 mooseError(
1450 "You must supply a vector of MultiMooseEnum object(s) when using addParam, even if the "
1451 "parameter is not required!");
1452}
1453
1454template <>
1455void
1456InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1457 const std::string & /*doc_string*/)
1458{
1459 mooseError("You must supply a vector of MultiMooseEnum object(s) when using addRequiredParam!");
1460}
1461
1462template <>
1463void
1464InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/)
1465{
1466 mooseError("You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1467 "is not required!");
1468}
1469
1470template <>
1471void
1472InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/)
1473{
1474 mooseError("You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1475 "parameter is not required!");
1476}
1477
1478template <>
1479void
1480InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
1481 const std::string & /*doc_string*/,
1482 const std::string & /*deprecation_message*/)
1483{
1484 mooseError("You must supply a MooseEnum object and the deprecation string when using "
1485 "addDeprecatedParam, even if the parameter is not required!");
1486}
1487
1488template <>
1489void
1490InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
1491 const std::string & /*doc_string*/,
1492 const std::string & /*deprecation_message*/)
1493{
1494 mooseError("You must supply a MultiMooseEnum object and the deprecation string when using "
1495 "addDeprecatedParam, even if the parameter is not required!");
1496}
1497
1498template <>
1499void
1500InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1501 const std::string & /*name*/,
1502 const std::string & /*doc_string*/,
1503 const std::string & /*deprecation_message*/)
1504{
1505 mooseError("You must supply a vector of MooseEnum object(s) and the deprecation string when "
1506 "using addDeprecatedParam, even if the parameter is not required!");
1507}
1508
1509template <>
1510void
1511InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & /*name*/,
1512 PostprocessorName & l_value,
1513 const Real & r_value)
1514{
1515 // Assign the default value so that it appears in the dump
1516 std::ostringstream oss;
1517 oss << r_value;
1518 l_value = oss.str();
1519}
1520
1521template <>
1522void
1523InputParameters::setParamHelper<PostprocessorName, int>(const std::string & /*name*/,
1524 PostprocessorName & l_value,
1525 const int & r_value)
1526{
1527 // Assign the default value so that it appears in the dump
1528 std::ostringstream oss;
1529 oss << r_value;
1530 l_value = oss.str();
1531}
1532
1533template <>
1534void
1535InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1536 FunctionName & l_value,
1537 const Real & r_value)
1538{
1539 // Assign the default value so that it appears in the dump
1540 std::ostringstream oss;
1541 oss << r_value;
1542 l_value = oss.str();
1543}
1544
1545template <>
1546void
1547InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1548 FunctionName & l_value,
1549 const int & r_value)
1550{
1551 // Assign the default value so that it appears in the dump
1552 std::ostringstream oss;
1553 oss << r_value;
1554 l_value = oss.str();
1555}
1556
1557template <>
1558void
1559InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1560 MaterialPropertyName & l_value,
1561 const Real & r_value)
1562{
1563 // Assign the default value so that it appears in the dump
1564 std::ostringstream oss;
1565 oss << r_value;
1566 l_value = oss.str();
1567}
1568
1569template <>
1570void
1571InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1572 MaterialPropertyName & l_value,
1573 const int & r_value)
1574{
1575 // Assign the default value so that it appears in the dump
1576 std::ostringstream oss;
1577 oss << r_value;
1578 l_value = oss.str();
1579}
1580
1581template <>
1582void
1583InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
1584 MooseFunctorName & l_value,
1585 const Real & r_value)
1586{
1587 // Assign the default value so that it appears in the dump
1588 std::ostringstream oss;
1589 oss << r_value;
1590 l_value = oss.str();
1591}
1592
1593template <>
1594void
1595InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
1596 MooseFunctorName & l_value,
1597 const int & r_value)
1598{
1599 // Assign the default value so that it appears in the dump
1600 std::ostringstream oss;
1601 oss << r_value;
1602 l_value = oss.str();
1603}
1604
1605template <>
1607InputParameters::getParamHelper<MooseEnum>(const std::string & name_in,
1608 const InputParameters & pars)
1609{
1610 const auto & name = pars.checkForRename(name_in);
1611 return pars.get<MooseEnum>(name);
1612}
1613
1614template <>
1616InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name_in,
1617 const InputParameters & pars)
1618{
1619 const auto & name = pars.checkForRename(name_in);
1620 return pars.get<MultiMooseEnum>(name);
1621}
1622
1623void
1624InputParameters::setReservedValues(const std::string & name_in,
1625 const std::set<std::string> & reserved)
1626{
1627 const auto & name = checkForRename(name_in);
1628 _params[name]._reserved_values = reserved;
1629}
1630
1631std::set<std::string>
1632InputParameters::reservedValues(const std::string & name_in) const
1633{
1634 const auto & name = checkForRename(name_in);
1635 auto it = _params.find(name);
1636 if (it == _params.end())
1637 return std::set<std::string>();
1638 return it->second._reserved_values;
1639}
1640
1641std::string
1643{
1644 if (const auto hit_node = getHitNode())
1645 return hit_node->fileLocation(/* with_column = */ false);
1646 return "";
1647}
1648
1649std::string
1651{
1652 if (const auto hit_node = getHitNode())
1653 return hit_node->fullpath();
1654 return "";
1655}
1656
1657const hit::Node *
1658InputParameters::getHitNode(const std::string & param) const
1659{
1660 return at(param)._hit_node;
1661}
1662
1663void
1664InputParameters::setHitNode(const std::string & param,
1665 const hit::Node & node,
1667{
1668 mooseAssert(node.type() == hit::NodeType::Field, "Must be a field");
1669 at(param)._hit_node = &node;
1670}
1671
1672std::string
1673InputParameters::inputLocation(const std::string & param) const
1674{
1675 if (const auto hit_node = getHitNode(param))
1676 return hit_node->fileLocation(/* with_column = */ false);
1677 return "";
1678}
1679
1680std::string
1681InputParameters::paramFullpath(const std::string & param) const
1682{
1683 if (const auto hit_node = getHitNode(param))
1684 return hit_node->fullpath();
1685 return "";
1686}
1687
1688void
1689InputParameters::checkParamName(const std::string & name) const
1690{
1691 const static pcrecpp::RE valid("[\\w:/]+");
1692 if (!valid.FullMatch(name))
1693 mooseError("Invalid parameter name: '", name, "'");
1694}
1695
1696bool
1697InputParameters::shouldIgnore(const std::string & name_in)
1698{
1699 const auto & name = checkForRename(name_in);
1700 auto it = _params.find(name);
1701 if (it != _params.end())
1702 return it->second._ignore;
1703 mooseError("Parameter ", name, " does not exist");
1704}
1705
1706std::set<std::string>
1707InputParameters::getGroupParameters(const std::string & group) const
1708{
1709 std::set<std::string> names;
1710 for (auto it = _params.begin(); it != _params.end(); ++it)
1711 if (it->second._group == group)
1712 names.emplace(it->first);
1713 return names;
1714}
1715
1716std::set<std::string>
1718{
1719 std::set<std::string> param_set;
1720 for (auto it = _params.begin(); it != _params.end(); ++it)
1721 param_set.emplace(it->first);
1722 return param_set;
1723}
1724
1725std::set<std::string>
1727{
1728 std::set<std::string> controllable;
1729 for (auto it = _params.begin(); it != _params.end(); ++it)
1730 if (it->second._controllable)
1731 controllable.emplace(it->first);
1732 return controllable;
1733}
1734
1735std::string
1736InputParameters::paramLocationPrefix(const std::string & param) const
1737{
1738 auto prefix = param + ":";
1739 if (!inputLocation(param).empty())
1740 prefix = inputLocation(param) + ": (" + paramFullpath(param) + ")";
1741 return prefix;
1742}
1743
1744std::string
1745InputParameters::rawParamVal(const std::string & param) const
1746{
1747 if (const auto hit_node = getHitNode(param))
1748 return hit_node->strVal();
1749 return "";
1750}
1751
1752std::string
1753InputParameters::varName(const std::string & var_param_name,
1754 const std::string & moose_object_with_var_param_name) const
1755{
1756 // Try the scalar version first
1757 std::string variable_name = getMooseType(var_param_name);
1758 if (variable_name == "")
1759 {
1760 auto vec = getVecMooseType(var_param_name);
1761
1762 // Catch the (very unlikely) case where a user specifies
1763 // variable = '' (the empty string)
1764 // in their input file. This could happen if e.g. something goes
1765 // wrong with dollar bracket expression expansion.
1766 if (vec.empty())
1767 mooseError("Error constructing object '",
1768 moose_object_with_var_param_name,
1769 "' while retrieving value for '",
1770 var_param_name,
1771 "' parameter! Did you forget to set '",
1772 var_param_name,
1773 "' or set it to '' (empty string) by accident?");
1774
1775 // When using vector variables, we are only going to use the first one in the list at the
1776 // interface level...
1777 variable_name = vec[0];
1778 }
1779
1780 return variable_name;
1781}
1782
1783void
1784InputParameters::renameParamInternal(const std::string & old_name,
1785 const std::string & new_name,
1786 const std::string & docstring,
1787 const std::string & removal_date)
1788{
1789 auto params_it = _params.find(old_name);
1790 if (params_it == _params.end())
1791 mooseError("Requested to rename parameter '",
1792 old_name,
1793 "' but that parameter name doesn't exist in the parameters object.");
1794 mooseAssert(params_it->second._deprecation_message.empty(),
1795 "Attempting to rename the parameter, '" << old_name << "', that is deprecated");
1796
1797 auto new_metadata = std::move(params_it->second);
1798 if (!docstring.empty())
1799 new_metadata._doc_string = docstring;
1800 _params.emplace(new_name, std::move(new_metadata));
1801 _params.erase(params_it);
1802
1803 auto values_it = _values.find(old_name);
1804 auto new_value = std::move(values_it->second);
1805 _values.emplace(new_name, std::move(new_value));
1806 _values.erase(values_it);
1807
1808 std::string deprecation_message;
1809 if (!removal_date.empty())
1810 deprecation_message = "'" + old_name + "' has been deprecated and will be removed on " +
1811 removal_date + ". Please use '" + new_name + "' instead.";
1812
1813 _old_to_new_name_and_dep.emplace(old_name, std::make_pair(new_name, deprecation_message));
1814 _new_to_old_names.emplace(new_name, old_name);
1815}
1816
1817void
1819 const std::string & new_name,
1820 const std::string & docstring,
1821 const std::string & removal_date)
1822{
1823 auto coupled_vars_it = _coupled_vars.find(old_name);
1824 if (coupled_vars_it == _coupled_vars.end())
1825 mooseError("Requested to rename coupled variable '",
1826 old_name,
1827 "' but that coupled variable name doesn't exist in the parameters object.");
1828
1829 _coupled_vars.insert(new_name);
1830 _coupled_vars.erase(coupled_vars_it);
1831
1832 renameParamInternal(old_name, new_name, docstring, removal_date);
1833}
1834
1835void
1836InputParameters::renameParam(const std::string & old_name,
1837 const std::string & new_name,
1838 const std::string & new_docstring)
1839{
1840 renameParamInternal(old_name, new_name, new_docstring, "");
1841}
1842
1843void
1844InputParameters::renameCoupledVar(const std::string & old_name,
1845 const std::string & new_name,
1846 const std::string & new_docstring)
1847{
1848 renameCoupledVarInternal(old_name, new_name, new_docstring, "");
1849}
1850
1851void
1852InputParameters::deprecateParam(const std::string & old_name,
1853 const std::string & new_name,
1854 const std::string & removal_date)
1855{
1856 renameParamInternal(old_name, new_name, "", removal_date);
1857}
1858
1859void
1860InputParameters::deprecateCoupledVar(const std::string & old_name,
1861 const std::string & new_name,
1862 const std::string & removal_date)
1863{
1864 renameCoupledVarInternal(old_name, new_name, "", removal_date);
1865}
1866
1867const std::string &
1868InputParameters::checkForRename(const std::string & name) const
1869{
1870 if (auto it = _old_to_new_name_and_dep.find(name); it != _old_to_new_name_and_dep.end())
1871 return it->second.first;
1872 else
1873 return name;
1874}
1875
1876std::vector<std::string>
1877InputParameters::paramAliases(const std::string & param_name) const
1878{
1879 mooseAssert(_values.find(param_name) != _values.end(),
1880 "The parameter we are searching for aliases for should exist in our parameter map");
1881 std::vector<std::string> aliases = {param_name};
1882
1883 for (const auto & pr : as_range(_new_to_old_names.equal_range(param_name)))
1884 aliases.push_back(pr.second);
1885
1886 return aliases;
1887}
1888
1889std::optional<Moose::DataFileUtils::Path>
1890InputParameters::queryDataFileNamePath(const std::string & name) const
1891{
1893}
1894
1895std::optional<std::string>
1896InputParameters::setupVariableNames(std::vector<VariableName> & names,
1897 const hit::Node & node,
1899{
1900 // Whether or not a name was found
1901 bool has_name = false;
1902 // Whether or not a default value (real) was found
1903 bool has_default = false;
1904
1905 // Search through the names for values that convert to Real values,
1906 // which are default values. If defaults are found, set appropriately
1907 // in the InputParameters object. Keep track of if names or defaults
1908 // were found because we don't allow having both
1909 for (const auto i : index_range(names))
1910 {
1911 auto & name = names[i];
1912 Real real_value;
1913 if (MooseUtils::convert<Real>(name, real_value, false))
1914 {
1915 has_default = true;
1916 defaultCoupledValue(node.path(), real_value, i);
1917 }
1918 else
1919 has_name = true;
1920 }
1921
1922 if (has_default)
1923 {
1924 if (has_name)
1925 return {"invalid value for '" + node.fullpath() +
1926 "': coupled vectors where some parameters are reals and others are variables are not "
1927 "supported"};
1928
1929 // Don't actually use the names if these don't represent names
1930 names.clear();
1931 }
1932
1933 return {};
1934}
1935
1936std::pair<std::string, const hit::Node *>
1937InputParameters::paramMessageContext(const std::string & param) const
1938{
1939 const hit::Node * node = nullptr;
1940
1941 std::string fullpath;
1942 // First try to find the parameter
1943 if (const hit::Node * param_node = getHitNode(param))
1944 {
1945 fullpath = param_node->fullpath();
1946 node = param_node;
1947 }
1948 // If no parameter node, hope for a block node
1949 else if (const hit::Node * block_node = getHitNode())
1950 {
1951 node = block_node;
1952 fullpath = block_node->fullpath() + "/" + param;
1953 }
1954 // Didn't find anything, at least use the parameter
1955 else
1956 fullpath = param;
1957
1958 return {fullpath + ": ", node};
1959}
1960
1961std::string
1962InputParameters::paramMessagePrefix(const std::string & param) const
1963{
1964 auto [prefix, node] = paramMessageContext(param);
1965 if (node)
1966 prefix = Moose::hitMessagePrefix(*node) + prefix;
1967 return prefix;
1968}
1969
1970[[noreturn]] void
1972 const bool with_prefix /* = true */,
1973 const hit::Node * node /* = nullptr */,
1974 const bool show_trace /* = true */) const
1975{
1976 // Find the context of the app if we can. This will let our errors be
1977 // prefixed by the multiapp name (if applicable) and will flush the
1978 // console before outputting an error
1979 MooseApp * app = nullptr;
1980 if (isMooseBaseObject() && have_parameter<MooseApp *>(MooseBase::app_param))
1981 app = get<MooseApp *>(MooseBase::app_param);
1982
1983 MooseBase::callMooseError(app, *this, msg, with_prefix, node, show_trace);
1984}
InputParameters emptyInputParameters()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363
std::array< Real, 2 > values
Definition MortarUtils.C:52
char ** vars
Class that is used as a parameter to commandLineParamSet() that allows only the CommandLine to set th...
Class that is used as a parameter to setHitNode(param) that allows only relevant classes to set the h...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void mooseError(Args &&... args) const
Emits an error prefixed with the object information, if available.
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class.
bool collapseSyntaxNesting() const
virtual void clear() override
std::vector< std::string > getVecMooseType(const std::string &name) const
std::vector< std::string > _buildable_types
The parameter is used to restrict types that can be built.
std::set< std::string > getGroupParameters(const std::string &group) const
Return names of parameters within a group.
bool _finalized
Whether or not we've called finalize() on these parameters yet.
bool isKokkosObject() const
Returns whether this InputParameters belongs to a Kokkos object Checks whether MooseBase::kokkos_obje...
bool isParamDefined(const std::string &name) const
Method returns true if the parameter is defined for any type.
const std::vector< std::tuple< std::string, Moose::RelationshipManagerType, Moose::RelationshipManagerInputParameterCallback > > & getBuildableRelationshipManagerTypes() const
Returns the list of buildable (or required) RelationshipManager object types for this object.
Metadata & at(const std::string &param_name)
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
Method for applying common parameters.
std::filesystem::path getFileBase(const std::optional< std::string > &param_name=std::optional< std::string >()) const
bool _show_deprecated_message
Flag for disabling deprecated parameters message, this is used by applyParameters to avoid dumping me...
bool mooseObjectSyntaxVisibility() const
const hit::Node * getHitNode() const
unsigned int numberDefaultCoupledValues(const std::string &coupling_name) const
Get the number of defaulted coupled value entries.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
bool paramSetByUser(const std::string &name) const
Deprecated method.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
std::optional< std::string > setupVariableNames(std::vector< VariableName > &names, const hit::Node &node, const Moose::PassKey< Moose::Builder >)
Entrypoint for the Builder to setup a std::vector<VariableName> parameter, which will setup the defau...
void setCoupledVar(const std::string &coupling_name, const std::string &value)
Set a coupled variable parameter to a single variable name.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
bool hasCoupledVar(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
std::optional< std::string > queryDeprecatedParamMessage(const std::string &name) const
bool isPrivate(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is private or not.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
bool _collapse_nesting
This parameter collapses one level of nesting in the syntax blocks.
std::string varName(const std::string &var_param_name, const std::string &moose_object_with_var_param_name) const
Determine the actual variable name from the given variable \emph parameter name.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
bool isParamSetByAddParam(const std::string &name) const
Returns whether or not the parameter was set due to addParam.
void checkParamName(const std::string &name) const
Make sure the parameter name doesn't have any invalid characters.
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a parameter and provide a new documentation string.
bool isMooseBaseObject() const
void commandLineParamSet(const std::string &name, const CommandLineParamSetKey)
Marks the command line parameter name as set by the CommandLine.
std::optional< std::pair< bool, std::string > > parameterRangeCheck(const Parameters::Value &value, const std::string &long_name, const std::string &short_name, const bool include_param_path)
Performs a range check on the parameter (which must have a range check)
std::string blockFullpath() const
std::optional< InputParameters::CommandLineMetadata > queryCommandLineMetadata(const std::string &name) const
void setDocString(const std::string &name, const std::string &doc)
Set the doc string of a parameter.
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
std::string rangeCheckedFunction(const std::string &name) const
Return the range check function for any parameter (empty string if it is not range checked)
void setHitNode(const std::string &param, const hit::Node &node, const SetParamHitNodeKey)
Sets the hit node associated with the parameter param to node.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
std::string getDocString(const std::string &name) const
Returns the documentation string for the specified parameter name.
const std::string & getSystemAttributeName() const
Get the system attribute name if it was registered.
bool _moose_object_syntax_visibility
This parameter hides derived MOOSE object types from appearing in syntax dumps.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
std::vector< std::string > paramAliases(const std::string &param_name) const
Return all the aliased names associated with param_name.
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
bool areAllRequiredParamsValid() const
This method returns true if all of the parameters in this object are valid (i.e.
void addCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
These methods add a coupled variable name pair.
void finalize(const std::string &parsing_syntax)
Finalizes the parameters, which must be done before constructing any objects with these parameters (t...
virtual void set_attributes(const std::string &name, bool inserted_only) override
Override from libMesh to set user-defined attributes on our parameter.
std::map< std::string, std::pair< std::string, std::string > > getAutoBuildVectors() const
Returns the auto build vectors for all parameters.
std::set< std::string >::const_iterator coupledVarsEnd() const
void renameCoupledVarInternal(const std::string &old_name, const std::string &new_name, const std::string &docstring, const std::string &removal_date)
void setReservedValues(const std::string &name, const std::set< std::string > &reserved)
Provide a set of reserved values for a parameter.
std::set< std::string > getControllableParameters() const
Return list of controllable parameters.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
std::multimap< std::string, std::string > _new_to_old_names
A map from derived-class/blessed parameter names to associated base-class/deprecated parameter names.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
std::optional< Moose::DataFileUtils::Path > queryDataFileNamePath(const std::string &name) const
void renameParameterGroup(const std::string &old_name, const std::string &new_name)
This method renames a parameter group.
void setDocUnit(const std::string &name, const std::string &doc_unit)
Set the unit string of a parameter.
std::set< std::string >::const_iterator coupledVarsBegin() const
Methods returning iterators to the coupled variables names stored in this InputParameters object.
void renameParamInternal(const std::string &old_name, const std::string &new_name, const std::string &docstring, const std::string &removal_date)
std::string getDocUnit(const std::string &name) const
Returns the documentation unit string for the specified parameter name.
void renameCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a coupled variable and provide a new documentation string.
bool isParamRequired(const std::string &name) const
Returns a boolean indicating whether the specified parameter is required or not.
const std::string & getObjectType() const
bool isFinalized() const
std::string _class_description
The class description for the owning object.
const std::string & getObjectName() const
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available.
const hit::Node * getHitNode(const std::string &param) const
InputParameters & operator=(const InputParameters &rhs)
bool isCommandLineParameter(const std::string &name) const
const std::vector< std::string > & getBuildableTypes() const
Returns the list of buildable types as a std::vector<std::string>
const hit::Node * _hit_node
The hit node representing the syntax that created these parameters, if any.
const std::set< ExecFlagType > & getControllableExecuteOnTypes(const std::string &name) const
Return the allowed execute flags for a controllable parameter.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
bool shouldIgnore(const std::string &name)
Whether to ignore the value of an input parameter set in the input file or from the command line.
bool hasDefault(const std::string &param_name) const
Return whether a parameter has a default.
std::string inputLocation(const std::string &param) const
void addDeprecatedCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date="")
This method adds a deprecated coupled variable name pair.
std::string rawParamVal(const std::string &param) const
void deprecateParam(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void makeParamNotRequired(const std::string &name)
Changes the parameter to not be required.
std::string paramMessagePrefix(const std::string &param) const
Get a prefix for messages associated with a parameter.
void setDeprecatedVarDocString(const std::string &new_name, const std::string &doc_string)
Private method for setting deprecated coupled variable documentation strings.
std::string paramFullpath(const std::string &param) const
const std::vector< VariableName > & getCoupledVar(const std::string &coupling_name) const
Get a coupled variable parameter.
std::set< std::string > getParametersList() const
std::string blockLocation() const
std::set< std::string > reservedValues(const std::string &name) const
Get a set of reserved parameter values.
void checkParams(const std::string &parsing_syntax)
This function checks parameters stored in the object to make sure they are in the correct state as th...
std::string paramLocationPrefix(const std::string &param) const
Returns a prefix containing the parameter name and location (if available)
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
std::pair< std::string, const hit::Node * > paramMessageContext(const std::string &param) const
Get the context associated with a parameter for a message.
std::vector< std::tuple< std::string, Moose::RelationshipManagerType, Moose::RelationshipManagerInputParameterCallback > > _buildable_rm_types
The RelationshipManagers that this object may either build or require.
bool hasDefaultCoupledValue(const std::string &coupling_name) const
Return whether or not the requested parameter has a default coupled value.
const std::string * queryObjectType() const
std::unordered_map< std::string, std::string > _new_to_deprecated_coupled_vars
A map from deprecated coupled variable names to the new blessed name.
std::string getGroupName(const std::string &param_name) const
This method retrieves the group name for the passed parameter name if one exists.
InputParameters & operator+=(const InputParameters &rhs)
std::map< std::string, Metadata > _params
The actual parameter data.
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false)
Apply values from a single parameter in common, to a single parameter stored in this object.
void addRequiredCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
std::string getClassDescription() const
Returns the class description.
void registerBuildableTypes(const std::string &names)
This method is here to indicate which Moose types a particular Action may build.
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
void applyCoupledVar(const InputParameters &common, const std::string &var_name)
Apply properties of a single coupled variable in common, to a single coupled variable stored in this ...
bool isParamDeprecated(const std::string &name) const
Returns True if the parameters is deprecated.
bool isControllable(const std::string &name) const
Returns a Boolean indicating whether the specified parameter is controllable.
void setGlobalCommandLineParam(const std::string &name)
Sets the command line parameter with name as global.
const std::string & getBase() const
bool hasBase() const
void moveParamToGroup(const std::string &name, const std::string &group_name)
This method moves a single parameter to a different group than the one it is already assigned to (for...
std::set< std::string > _coupled_vars
The coupled variables set.
std::map< std::string, std::pair< std::string, std::string > > _old_to_new_name_and_dep
A map from base-class/deprecated parameter names to derived-class/blessed parameter names and the dep...
std::vector< std::string > missingRequiredParamErrors(const std::string &parsing_syntax, const std::set< std::string > &skip_required_params={}, bool skip_private=false) const
Return errors for missing required parameters.
bool isRangeChecked(const std::string &param_name) const
Return whether a parameter has a range check.
bool _allow_copy
A flag for toggling the error message in the copy constructor.
const InputParameters::CommandLineMetadata & getCommandLineMetadata(const std::string &name) const
const std::string & checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
const std::string & getDescription(const std::string &name) const
Get the documentation string for a parameter.
void applyCommonUserSetParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Variant of applyParameters that only applies parameters explicitly set by the user in common (i....
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Method for applying common parameters.
void callMooseError(std::string msg, const bool with_prefix=true, const hit::Node *node=nullptr, const bool show_trace=true) const
Internal helper for calling back to mooseError(), ideally from the underlying MooseBase object if it ...
Base class for MOOSE-based applications.
Definition MooseApp.h:110
static const std::string kokkos_object_param
The name of the parameter that indicates an object is a Kokkos functor.
Definition MooseBase.h:64
static const std::string moose_base_param
The name of the parameter that contains the moose system base.
Definition MooseBase.h:61
static const std::string name_param
The name of the parameter that contains the object name.
Definition MooseBase.h:55
static const std::string type_param
The name of the parameter that contains the object type.
Definition MooseBase.h:53
void callMooseError(std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
External method for calling moose error with added object context.
Definition MooseBase.C:105
static const std::string app_param
The name of the parameter that contains the MooseApp.
Definition MooseBase.h:59
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Scoped helper for setting Moose::_throw_on_error during this scope.
Definition Moose.h:308
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
void remove(std::string_view)
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
Path getPath(std::string path, const GetPathOptions &options={})
Get the data path for a given path, searching the registered data.
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
The type for the callback to set RelationshipManager parameters.
RelationshipManagerType
Main types of Relationship Managers.
std::string hitMessagePrefix(const hit::Node &node)
Get the prefix to be associated with a hit node for a message.
Definition Moose.C:913
Structure for storing information about a command line parameter.
std::optional< CommandLineMetadata > _cl_data
The data pertaining to a command line parameter (empty if not a command line param)
std::set< ExecFlagType > _controllable_flags
Controllable execute flag restriction.
std::optional< Moose::DataFileUtils::Path > _data_file_name_path
The searched path information pertaining to a DataFileName parameter.
const hit::Node * _hit_node
Original location of parameter node; used for error messages.
Options to be passed to getPath().
bool graceful
Whether or not to error whenever a path is not found.
std::optional< std::string > base
The base path by which to search for relative paths.
bool search_all_data
Whether or not to search all registered data.
Representation of a data file path.