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 std::vector<std::string> required_param_errors;
595 for (const auto & it : *this)
596 {
597 const auto & param_name = checkForRename(it.first);
598 if (!isParamValid(param_name) && isParamRequired(param_name))
599 {
600 // check if an old, deprecated name exists for this parameter that may be specified
601 auto oit = _new_to_deprecated_coupled_vars.find(param_name);
602 if (oit != _new_to_deprecated_coupled_vars.end() && isParamValid(oit->second))
603 continue;
604
605 required_param_errors.push_back("missing required parameter '" + parampath + "/" +
606 param_name + "'\n\tDoc String: \"" +
607 getDocString(param_name) + "\"");
608 }
609 }
610
611 if (required_param_errors.size())
612 mooseError(MooseUtils::stringJoin(required_param_errors, "\n"));
613
614 // Range checked parameters
615 for (const auto & [name, param_ptr] : *this)
616 {
617 if (const auto error = parameterRangeCheck(*param_ptr, parampath + "/" + name, name, false))
618 {
619 if (error->first)
620 paramError(name, error->second);
621 else
622 mooseError("For range checked parameter '" + name + "': " + error->second);
623 }
624 }
625
626 // Controllable parameters
627 for (const auto & param_name : getControllableParameters())
628 {
629 if (isPrivate(param_name))
630 paramError(param_name,
631 "private parameter '" + paramFullpath(param_name) + "' marked controllable");
632
633 std::optional<std::string> error;
634 checkMooseType(NonlinearVariableName, param_name);
635 checkMooseType(AuxVariableName, param_name);
636 checkMooseType(VariableName, param_name);
637 checkMooseType(BoundaryName, param_name);
638 checkMooseType(SubdomainName, param_name);
639 checkMooseType(PostprocessorName, param_name);
640 checkMooseType(VectorPostprocessorName, param_name);
641 checkMooseType(UserObjectName, param_name);
642 checkMooseType(MaterialPropertyName, param_name);
643 if (error)
644 paramError(param_name, *error);
645 }
646}
647
648std::optional<std::pair<bool, std::string>>
649InputParameters::parameterRangeCheck(const Parameters::Value & value,
650 const std::string & long_name,
651 const std::string & short_name,
652 const bool include_param_path)
653{
654#define dynamicCastRangeCheck(type, up_type, long_name, short_name) \
655 do \
656 { \
657 if (const auto scalar_p = dynamic_cast<const InputParameters::Parameter<type> *>(&value)) \
658 return rangeCheck<type, up_type>(long_name, short_name, *scalar_p, include_param_path); \
659 if (const auto vector_p = \
660 dynamic_cast<const InputParameters::Parameter<std::vector<type>> *>(&value)) \
661 return rangeCheck<type, up_type>(long_name, short_name, *vector_p, include_param_path); \
662 } while (0)
663
664 dynamicCastRangeCheck(Real, Real, long_name, short_name);
665 dynamicCastRangeCheck(int, long, long_name, short_name);
666 dynamicCastRangeCheck(long, long, long_name, short_name);
667 dynamicCastRangeCheck(unsigned int, long, long_name, short_name);
668#undef dynamicCastRangeCheck
669
670 return {};
671}
672
673void
674InputParameters::finalize(const std::string & parsing_syntax)
675{
676 mooseAssert(!isFinalized(), "Already finalized");
677
678 checkParams(parsing_syntax);
679
680 // Set parameters that represent file types
681 for (const auto & name_value : *this)
682 {
683 const auto & param_name = name_value.first;
684 const auto & param_value = name_value.second;
685
686 // Helper for setting a file typed parameter value
687 const auto set_filename = [&](auto & value)
688 {
689 constexpr bool is_data_file_name =
690 std::is_same_v<std::decay_t<decltype(value)>, DataFileName>;
691
692 // We have behavior (which is gross) that requires that for
693 // everything but DataFileName, if the value is empty we
694 // don't bother looking for it
695 if constexpr (!is_data_file_name)
696 {
697 if (value.empty())
698 return;
699 }
700
701 // Setup options for searching for the path
703 // Associate relative path searches with the folder
704 // that input file that has this parameter is located
705 options.base = getFileBase(param_name);
706 // If we don't explicitly have a DataFileName parameter,
707 // we only want to augment cases where a data name is
708 // explicitly set (like moose:file). We don't want to
709 // search all other data. To presere previous behavior,
710 // we also don't want to error if nothing is found; for
711 // example if a relative or absolute path is not found.
712 // The only time we'll error is if the data name is
713 // explicitly set and the path doesn't exist in the data
714 // or if that data name isn't registered.
715 if constexpr (!is_data_file_name)
716 {
717 options.search_all_data = false;
718 options.graceful = true;
719 }
720
722 try
723 {
724 Moose::ScopedThrowOnError scoped_throw_on_error;
725 path = Moose::DataFileUtils::getPath(value, options);
726 }
727 catch (std::exception & e)
728 {
729 paramError(param_name, e.what());
730 }
731
732 value = path.path;
733 at(param_name)._data_file_name_path = path;
734 };
735
736#define set_if_filename(type) \
737 else if (auto type_value = dynamic_cast<Parameters::Parameter<type> *>(param_value.get())) \
738 set_filename(type_value->set()); \
739 else if (auto type_values = dynamic_cast<Parameters::Parameter<std::vector<type>> *>( \
740 param_value.get())) for (auto & value : type_values->set()) set_filename(value)
741
742 if (false)
743 ;
744 set_if_filename(FileName);
745 set_if_filename(FileNameNoExtension);
746 set_if_filename(MeshFileName);
747 set_if_filename(MatrixFileName);
748 set_if_filename(DataFileName);
749#undef set_if_filename
750 }
751
752 _finalized = true;
753}
754
755std::filesystem::path
756InputParameters::getFileBase(const std::optional<std::string> & param_name) const
757{
758 mooseAssert(!have_parameter<std::string>("_app_name"),
759 "Not currently setup to work with app FileName parameters");
760
761 const hit::Node * hit_node = nullptr;
762
763 // Context from the individual parameter
764 if (param_name)
765 hit_node = getHitNode(*param_name);
766 // Context from the parameters
767 if (!hit_node)
768 hit_node = getHitNode();
769 // No hit node, so use the cwd (no input files)
770 if (!hit_node)
771 return std::filesystem::current_path();
772
773 // Find any context that isn't command line arguments
774 while (hit_node && hit_node->filename() == "CLI_ARGS")
775 hit_node = hit_node->parent();
776
777 // Failed to find a node up the tree that isn't a command line argument
778 if (!hit_node)
779 {
780 const std::string error = "Input context was set via a command-line argument and does not have "
781 "sufficient context for determining a file path.";
782 if (param_name)
783 paramError(*param_name, error);
784 else
785 mooseError(error);
786 }
787
788 return std::filesystem::absolute(std::filesystem::path(hit_node->filename()).parent_path());
789}
790
791bool
792InputParameters::isRangeChecked(const std::string & param_name) const
793{
794 const auto & name = checkForRename(param_name);
795 return !_params.find(name)->second._range_function.empty();
796}
797
798std::string
799InputParameters::rangeCheckedFunction(const std::string & param_name) const
800{
801 const auto & name = checkForRename(param_name);
802 return _params.at(name)._range_function;
803}
804
805bool
806InputParameters::hasDefault(const std::string & param_name) const
807{
808 const auto & name = checkForRename(param_name);
809 if (hasDefaultCoupledValue(name))
810 return true;
811 // If it has a default, it's already valid
812 else if (isParamSetByAddParam(name))
813 return true;
814 else if (isParamValid(name))
815 mooseError("No way to know if the parameter '", param_name, "' has a default");
816 else
817 return false;
818}
819
820bool
821InputParameters::hasCoupledVar(const std::string & coupling_name) const
822{
823 return _coupled_vars.find(coupling_name) != _coupled_vars.end();
824}
825
826void
827InputParameters::setCoupledVar(const std::string & coupling_name, const std::string & value)
828{
829 setCoupledVar(coupling_name, std::vector<VariableName>{value});
830}
831
832void
833InputParameters::setCoupledVar(const std::string & coupling_name,
834 const std::vector<VariableName> & values)
835{
836 const auto & actual_name = checkForRename(coupling_name);
837
838 if (!hasCoupledVar(actual_name))
839 mooseError("Unable to set coupled variable parameter '",
840 coupling_name,
841 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
842
843 set<std::vector<VariableName>>(actual_name) = values;
844}
845
846const std::vector<VariableName> &
847InputParameters::getCoupledVar(const std::string & coupling_name) const
848{
849 const auto & actual_name = checkForRename(coupling_name);
850
851 if (!hasCoupledVar(actual_name))
852 mooseError("Unable to get coupled variable parameter '",
853 coupling_name,
854 "' because it was not added with addCoupledVar or addRequiredCoupledVar.");
855
856 return get<std::vector<VariableName>>(actual_name);
857}
858
859bool
860InputParameters::hasDefaultCoupledValue(const std::string & coupling_name) const
861{
862 return _params.count(coupling_name) > 0 && _params.at(coupling_name)._have_coupled_default &&
863 _coupled_vars.count(coupling_name) > 0;
864}
865
866void
867InputParameters::defaultCoupledValue(const std::string & coupling_name, Real value, unsigned int i)
868{
869 const auto & actual_name = checkForRename(coupling_name);
870 _params[actual_name]._coupled_default.resize(i + 1);
871 _params[actual_name]._coupled_default[i] = value;
872 _params[actual_name]._have_coupled_default = true;
873}
874
875Real
876InputParameters::defaultCoupledValue(const std::string & coupling_name, unsigned int i) const
877{
878 auto value_it = _params.find(coupling_name);
879
880 if (value_it == _params.end() || !value_it->second._have_coupled_default)
881 mooseError("Attempted to retrieve default value for coupled variable '",
882 coupling_name,
883 "' when none was provided. \n\nThere are three reasons why this may have "
884 "occurred:\n 1. The other version of params.addCoupledVar() should be used in order "
885 "to provide a default value. \n 2. This should have been a required coupled "
886 "variable added with params.addRequiredCoupledVar() \n 3. The call to get the "
887 "coupled value should have been properly guarded with isCoupled()\n");
888
889 return value_it->second._coupled_default.at(i);
890}
891
892unsigned int
893InputParameters::numberDefaultCoupledValues(const std::string & coupling_name) const
894{
895 auto value_it = _params.find(coupling_name);
896 if (value_it == _params.end())
897 mooseError("Attempted to retrieve default value for coupled variable '",
898 coupling_name,
899 "' when none was provided.");
900 return value_it->second._coupled_default.size();
901}
902
903std::map<std::string, std::pair<std::string, std::string>>
905{
906 std::map<std::string, std::pair<std::string, std::string>> abv;
907 for (auto it = _params.begin(); it != _params.end(); ++it)
908 {
909 if (!it->second._autobuild_vecs.first.empty())
910 abv[it->first] = it->second._autobuild_vecs;
911 }
912 return abv;
913}
914
915std::string
916InputParameters::type(const std::string & name_in) const
917{
918 const auto & name = checkForRename(name_in);
919 if (!_values.count(name))
920 mooseError("Parameter \"", name, "\" not found.\n\n", *this);
921
922 if (_coupled_vars.find(name) != _coupled_vars.end())
923 return "std::vector<VariableName>";
924 else if (_params.count(name) > 0 && !_params.at(name)._custom_type.empty())
925 return _params.at(name)._custom_type;
926 return _values.at(name)->type();
927}
928
929std::string
930InputParameters::getMooseType(const std::string & name_in) const
931{
932 const auto & name = checkForRename(name_in);
933 std::string var;
934
935 if (have_parameter<VariableName>(name))
936 var = get<VariableName>(name);
937 else if (have_parameter<NonlinearVariableName>(name))
938 var = get<NonlinearVariableName>(name);
939 else if (have_parameter<LinearVariableName>(name))
940 var = get<LinearVariableName>(name);
941 else if (have_parameter<AuxVariableName>(name))
942 var = get<AuxVariableName>(name);
943 else if (have_parameter<PostprocessorName>(name))
944 var = get<PostprocessorName>(name);
945 else if (have_parameter<VectorPostprocessorName>(name))
946 var = get<VectorPostprocessorName>(name);
947 else if (have_parameter<FunctionName>(name))
948 var = get<FunctionName>(name);
949 else if (have_parameter<UserObjectName>(name))
950 var = get<UserObjectName>(name);
951 else if (have_parameter<MaterialPropertyName>(name))
952 var = get<MaterialPropertyName>(name);
953 else if (have_parameter<std::string>(name))
954 var = get<std::string>(name);
955
956 return var;
957}
958
959std::vector<std::string>
960InputParameters::getVecMooseType(const std::string & name_in) const
961{
962 const auto & name = checkForRename(name_in);
963 std::vector<std::string> svars;
964
965 if (have_parameter<std::vector<VariableName>>(name))
966 {
967 std::vector<VariableName> vars = get<std::vector<VariableName>>(name);
968 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
969 }
970 else if (have_parameter<std::vector<NonlinearVariableName>>(name))
971 {
972 std::vector<NonlinearVariableName> vars = get<std::vector<NonlinearVariableName>>(name);
973 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
974 }
975 else if (have_parameter<std::vector<AuxVariableName>>(name))
976 {
977 std::vector<AuxVariableName> vars = get<std::vector<AuxVariableName>>(name);
978 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
979 }
980 else if (have_parameter<std::vector<MaterialPropertyName>>(name))
981 {
982 std::vector<MaterialPropertyName> vars = get<std::vector<MaterialPropertyName>>(name);
983 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
984 }
985 else if (have_parameter<std::vector<std::string>>(name))
986 {
987 std::vector<std::string> vars = get<std::vector<std::string>>(name);
988 std::copy(vars.begin(), vars.end(), std::back_inserter(svars));
989 }
990
991 return svars;
992}
993
994bool
996{
997 return have_parameter<std::string>(MooseBase::type_param) &&
998 get<std::string>(MooseBase::type_param).size() &&
999 have_parameter<std::string>(MooseBase::name_param);
1000}
1001
1002const std::string *
1004{
1005 return have_parameter<std::string>(MooseBase::type_param)
1006 ? &get<std::string>(MooseBase::type_param)
1007 : nullptr;
1008}
1009
1010const std::string &
1012{
1013 if (const auto type_ptr = queryObjectType())
1014 return *type_ptr;
1015 ::mooseError("InputParameters::getObjectType(): Missing '", MooseBase::type_param, "' param");
1016}
1017
1018const std::string &
1020{
1021 if (!have_parameter<std::string>(MooseBase::name_param))
1022 ::mooseError("InputParameters::getObjectName(): Missing '", MooseBase::name_param, "' param");
1023 return get<std::string>(MooseBase::name_param);
1024}
1025
1026void
1027InputParameters::addParamNamesToGroup(const std::string & space_delim_names,
1028 const std::string group_name)
1029{
1030 std::vector<std::string> elements;
1031 MooseUtils::tokenize(space_delim_names, elements, 1, " \t\n\v\f\r"); // tokenize on whitespace
1032
1033 // Since we don't require types (templates) for this method, we need
1034 // to get a raw list of parameter names to compare against.
1035 std::set<std::string> param_names;
1036 for (const auto & it : *this)
1037 param_names.insert(it.first);
1038
1039 for (const auto & param_name : elements)
1040 if (_params.count(param_name) > 0)
1041 {
1042 std::string & group = _params[param_name]._group;
1043 if (!group.empty() && group == group_name)
1044 mooseError(
1045 "The parameter '", param_name, "' has already been added to the group '", group, "'.");
1046 group = group_name;
1047 }
1048 else
1049 mooseError("Unable to find a parameter with name: ",
1050 param_name,
1051 " when adding to group ",
1052 group_name,
1053 '.');
1054}
1055
1056void
1057InputParameters::moveParamToGroup(const std::string & name, const std::string & group_name)
1058{
1059 if (_params.count(name) == 0)
1060 mooseError(
1061 "Unable to find a parameter with name: ", name, " when moving to group ", group_name, '.');
1062 _params[name]._group = group_name;
1063}
1064
1065void
1066InputParameters::renameParameterGroup(const std::string & old_name, const std::string & new_name)
1067{
1068 for (auto & param : _params)
1069 if (param.second._group == old_name)
1070 param.second._group = new_name;
1071}
1072
1073void
1075{
1076 auto & cl_data = at(checkForRename(name))._cl_data;
1077 if (!cl_data)
1078 mooseError("InputParameters::setGlobalCommandLineParam: The parameter '",
1079 name,
1080 "' is not a command line parameter");
1081 cl_data->global = true;
1082}
1083
1084bool
1085InputParameters::isCommandLineParameter(const std::string & name) const
1086{
1087 return at(checkForRename(name))._cl_data.has_value();
1088}
1089
1090std::optional<InputParameters::CommandLineMetadata>
1091InputParameters::queryCommandLineMetadata(const std::string & name) const
1092{
1093 const auto & cl_data = at(checkForRename(name))._cl_data;
1094 if (!cl_data)
1095 return {};
1096 return *cl_data;
1097}
1098
1100InputParameters::getCommandLineMetadata(const std::string & name) const
1101{
1102 const auto & cl_data = at(checkForRename(name))._cl_data;
1103 if (!cl_data)
1104 mooseError("InputParameters::getCommandLineMetadata: The parameter '",
1105 name,
1106 "' is not a command line parameter");
1107 return *cl_data;
1108}
1109
1110void
1112{
1113 auto & cl_data = at(checkForRename(name))._cl_data;
1114 if (!cl_data)
1115 mooseError("InputParameters::commandLineParamSet: The parameter '",
1116 name,
1117 "' is not a command line parameter");
1118 cl_data->set_by_command_line = true;
1119}
1120
1121std::string
1122InputParameters::getGroupName(const std::string & param_name_in) const
1123{
1124 const auto & param_name = checkForRename(param_name_in);
1125 auto it = _params.find(param_name);
1126 if (it != _params.end())
1127 return it->second._group;
1128 return std::string();
1129}
1130
1131void
1133 const std::vector<std::string> & exclude,
1134 const bool allow_private)
1135{
1136 // If we're applying all of the things, also associate the top level hit node
1137 if (exclude.empty() && !getHitNode() && common.getHitNode())
1138 setHitNode(*common.getHitNode(), {});
1139
1140 // Loop through the common parameters
1141 for (const auto & it : common)
1142 {
1143 // Common parameter name
1144 const std::string & common_name = it.first;
1145 // Continue to next parameter, if the current is in list of excluded parameters
1146 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1147 continue;
1148
1149 applyParameter(common, common_name, allow_private);
1150 }
1151
1152 // Loop through the coupled variables
1153 for (const auto & var_name : common._coupled_vars)
1154 {
1155 // Continue to next variable, if the current is in list of excluded parameters
1156 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1157 continue;
1158
1159 applyCoupledVar(common, var_name);
1160 }
1161}
1162
1163void
1165 const std::vector<std::string> & exclude,
1166 const bool allow_private)
1167{
1168 for (const auto & it : common)
1169 {
1170 const std::string & common_name = it.first;
1171 if (std::find(exclude.begin(), exclude.end(), common_name) != exclude.end())
1172 continue;
1173 if (!common.isParamSetByUser(common_name))
1174 continue;
1175 applyParameter(common, common_name, allow_private);
1176 }
1177
1178 for (const auto & var_name : common._coupled_vars)
1179 {
1180 if (std::find(exclude.begin(), exclude.end(), var_name) != exclude.end())
1181 continue;
1182 if (!common.isParamSetByUser(var_name))
1183 continue;
1184 applyCoupledVar(common, var_name);
1185 }
1186}
1187
1188void
1190 const std::vector<std::string> & include,
1191 bool allow_private)
1192{
1193 // Loop through the common parameters
1194 for (const auto & it : common)
1195 {
1196 // Common parameter name
1197 const std::string & common_name = it.first;
1198
1199 // Continue to next parameter, if the current is not in list of included parameters
1200 if (std::find(include.begin(), include.end(), common_name) == include.end())
1201 continue;
1202
1203 applyParameter(common, common_name, allow_private);
1204 }
1205
1206 // Loop through the coupled variables
1207 for (std::set<std::string>::const_iterator it = common.coupledVarsBegin();
1208 it != common.coupledVarsEnd();
1209 ++it)
1210 {
1211 // Variable name
1212 const std::string var_name = *it;
1213
1214 // Continue to next variable, if the current is not in list of included parameters
1215 if (std::find(include.begin(), include.end(), var_name) == include.end())
1216 continue;
1217
1218 applyCoupledVar(common, var_name);
1219 }
1220}
1221
1222void
1223InputParameters::applyCoupledVar(const InputParameters & common, const std::string & var_name)
1224{
1225 // Disable the display of deprecated message when applying common parameters, this avoids a dump
1226 // of messages
1228
1229 // If the local parameters has a coupled variable, populate it with the value from the common
1230 // parameters, if the common parameters has the coupled variable too
1231 if (hasCoupledVar(var_name))
1232 {
1233 if (common.hasDefaultCoupledValue(var_name))
1234 {
1235 // prepare a vector of default coupled values
1236 std::vector<Real> defaults(common.numberDefaultCoupledValues(var_name));
1237 for (unsigned int j = 0; j < common.numberDefaultCoupledValues(var_name); ++j)
1238 defaults[j] = common.defaultCoupledValue(var_name, j);
1239 addCoupledVar(var_name, defaults, common.getDocString(var_name));
1240 }
1241 else if (common.hasCoupledVar(var_name))
1242 addCoupledVar(var_name, common.getDocString(var_name));
1243 }
1244
1245 // Enable deprecated message printing
1247}
1248
1249void
1251 const std::string & common_name,
1252 bool allow_private)
1253{
1254 // Disable the display of deprecated message when applying common parameters, this avoids a dump
1255 // of messages
1257
1258 const auto & local_name = checkForRename(common_name);
1259
1260 // Extract the properties from the local parameter for the current common parameter name
1261 const bool local_exist = _values.find(local_name) != _values.end();
1262 const bool local_set = _params.count(local_name) > 0 && !_params[local_name]._set_by_add_param;
1263 const bool local_priv = allow_private ? false : isPrivate(local_name);
1264 const bool local_valid = isParamValid(local_name);
1265
1266 // Extract the properties from the common parameter
1267 const bool common_exist = common._values.find(common_name) != common._values.end();
1268 const bool common_priv = allow_private ? false : common.isPrivate(common_name);
1269 const bool common_valid = common.isParamValid(common_name);
1270
1271 /* In order to apply a common parameter 4 statements must be satisfied
1272 * (1) A local parameter must exist with the same name as the common parameter
1273 * (2) Common parameter must be valid and exist
1274 * (3) Local parameter must be invalid OR not have been set from its default
1275 * (4) Both cannot be private
1276 */
1277 if (local_exist && common_exist && common_valid && (!local_valid || !local_set) &&
1278 (!common_priv || !local_priv))
1279 {
1280 remove(local_name);
1281 _values[local_name] = common._values.find(common_name)->second->clone();
1282 set_attributes(local_name, false);
1283 _params[local_name]._set_by_add_param =
1284 libmesh_map_find(common._params, common_name)._set_by_add_param;
1285 // Keep track of where this param came from if we can. This will enable us to
1286 // produce param errors from objects created within an action that link to
1287 // the parameter in the action
1288 at(local_name)._hit_node = common.getHitNode(common_name);
1289 }
1290 else if (!local_exist && !common_exist)
1291 mooseError("InputParameters::applyParameter(): Attempted to apply invalid parameter \"",
1292 common_name,
1293 "\"");
1294
1295 // Enable deprecated message printing
1297}
1298
1300bool
1301InputParameters::paramSetByUser(const std::string & name) const
1302{
1303 mooseDeprecated("paramSetByUser() is deprecated. Use isParamSetByUser() instead.");
1304 return isParamSetByUser(name);
1305}
1306
1307bool
1308InputParameters::isParamSetByUser(const std::string & name_in) const
1309{
1310 const auto & name = checkForRename(name_in);
1311 // Invalid; for sure not set by the user
1312 if (!isParamValid(name))
1313 return false;
1314 // Parameter is not located in the list (called Parameters::set)
1315 if (!_params.count(name))
1316 return false;
1317 // Special case for a command line option, which is a private parameter
1318 if (const auto cl_data = queryCommandLineMetadata(name))
1319 return cl_data->set_by_command_line;
1320 // Not a command line option, not set by addParam and not private
1321 return !_params.at(name)._set_by_add_param && !_params.at(name)._is_private;
1322}
1323
1324bool
1325InputParameters::isParamDefined(const std::string & name_in) const
1326{
1327 const auto & name = checkForRename(name_in);
1328 return _params.count(name) > 0;
1329}
1330
1331const std::string &
1332InputParameters::getDescription(const std::string & name_in) const
1333{
1334 const auto & name = checkForRename(name_in);
1335 auto it = _params.find(name);
1336 if (it == _params.end())
1337 mooseError("No parameter exists with the name ", name);
1338 return it->second._doc_string;
1339}
1340
1341template <>
1342void
1343InputParameters::addRequiredParam<MooseEnum>(const std::string & name,
1344 const MooseEnum & moose_enum,
1345 const std::string & doc_string)
1346{
1347 InputParameters::set<MooseEnum>(name) = moose_enum; // valid parameter is set by set_attributes
1348 auto & metadata = _params[name];
1349 metadata._required = true;
1350 metadata._doc_string = doc_string;
1351}
1352
1353template <>
1354void
1355InputParameters::addRequiredParam<MultiMooseEnum>(const std::string & name,
1356 const MultiMooseEnum & moose_enum,
1357 const std::string & doc_string)
1358{
1359 InputParameters::set<MultiMooseEnum>(name) =
1360 moose_enum; // valid parameter is set by set_attributes
1361 auto & metadata = _params[name];
1362 metadata._required = true;
1363 metadata._doc_string = doc_string;
1364}
1365
1366template <>
1367void
1368InputParameters::addRequiredParam<std::vector<MooseEnum>>(
1369 const std::string & name,
1370 const std::vector<MooseEnum> & moose_enums,
1371 const std::string & doc_string)
1372{
1373 InputParameters::set<std::vector<MooseEnum>>(name) =
1374 moose_enums; // valid parameter is set by set_attributes
1375 auto & metadata = _params[name];
1376 metadata._required = true;
1377 metadata._doc_string = doc_string;
1378}
1379
1380template <>
1381void
1382InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(
1383 const std::string & name,
1384 const std::vector<MultiMooseEnum> & moose_enums,
1385 const std::string & doc_string)
1386{
1387 mooseAssert(
1388 moose_enums.size() == 1,
1389 "Only 1 MultiMooseEnum is supported in addRequiredParam<std::vector<MultiMooseEnum>> for " +
1390 name);
1391 mooseAssert(!moose_enums[0].items().empty(),
1392 "The MultiMooseEnum in addRequiredParam<std::vector<MultiMooseEnum>> is empty for " +
1393 name);
1394 InputParameters::set<std::vector<MultiMooseEnum>>(name) =
1395 moose_enums; // valid parameter is set by set_attributes
1396 auto & metadata = _params[name];
1397 metadata._required = true;
1398 metadata._doc_string = doc_string;
1399}
1400
1401template <>
1402void
1403InputParameters::addParam<MooseEnum>(const std::string & /*name*/,
1404 const std::string & /*doc_string*/)
1405{
1406 mooseError("You must supply a MooseEnum object when using addParam, even if the parameter is not "
1407 "required!");
1408}
1409
1410template <>
1411void
1412InputParameters::addParam<MultiMooseEnum>(const std::string & /*name*/,
1413 const std::string & /*doc_string*/)
1414{
1415 mooseError("You must supply a MultiMooseEnum object when using addParam, even if the parameter "
1416 "is not required!");
1417}
1418
1419template <>
1420void
1421InputParameters::addParam<std::vector<MooseEnum>>(const std::string & /*name*/,
1422 const std::string & /*doc_string*/)
1423{
1424 mooseError("You must supply a vector of MooseEnum object(s) when using addParam, even if the "
1425 "parameter is not required!");
1426}
1427
1428template <>
1429void
1430InputParameters::addParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1431 const std::string & /*doc_string*/)
1432{
1433 mooseError(
1434 "You must supply a vector of MultiMooseEnum object(s) when using addParam, even if the "
1435 "parameter is not required!");
1436}
1437
1438template <>
1439void
1440InputParameters::addRequiredParam<std::vector<MultiMooseEnum>>(const std::string & /*name*/,
1441 const std::string & /*doc_string*/)
1442{
1443 mooseError("You must supply a vector of MultiMooseEnum object(s) when using addRequiredParam!");
1444}
1445
1446template <>
1447void
1448InputParameters::addPrivateParam<MooseEnum>(const std::string & /*name*/)
1449{
1450 mooseError("You must supply a MooseEnum object when using addPrivateParam, even if the parameter "
1451 "is not required!");
1452}
1453
1454template <>
1455void
1456InputParameters::addPrivateParam<MultiMooseEnum>(const std::string & /*name*/)
1457{
1458 mooseError("You must supply a MultiMooseEnum object when using addPrivateParam, even if the "
1459 "parameter is not required!");
1460}
1461
1462template <>
1463void
1464InputParameters::addDeprecatedParam<MooseEnum>(const std::string & /*name*/,
1465 const std::string & /*doc_string*/,
1466 const std::string & /*deprecation_message*/)
1467{
1468 mooseError("You must supply a MooseEnum object and the deprecation string when using "
1469 "addDeprecatedParam, even if the parameter is not required!");
1470}
1471
1472template <>
1473void
1474InputParameters::addDeprecatedParam<MultiMooseEnum>(const std::string & /*name*/,
1475 const std::string & /*doc_string*/,
1476 const std::string & /*deprecation_message*/)
1477{
1478 mooseError("You must supply a MultiMooseEnum object and the deprecation string when using "
1479 "addDeprecatedParam, even if the parameter is not required!");
1480}
1481
1482template <>
1483void
1484InputParameters::addDeprecatedParam<std::vector<MooseEnum>>(
1485 const std::string & /*name*/,
1486 const std::string & /*doc_string*/,
1487 const std::string & /*deprecation_message*/)
1488{
1489 mooseError("You must supply a vector of MooseEnum object(s) and the deprecation string when "
1490 "using addDeprecatedParam, even if the parameter is not required!");
1491}
1492
1493template <>
1494void
1495InputParameters::setParamHelper<PostprocessorName, Real>(const std::string & /*name*/,
1496 PostprocessorName & l_value,
1497 const Real & r_value)
1498{
1499 // Assign the default value so that it appears in the dump
1500 std::ostringstream oss;
1501 oss << r_value;
1502 l_value = oss.str();
1503}
1504
1505template <>
1506void
1507InputParameters::setParamHelper<PostprocessorName, int>(const std::string & /*name*/,
1508 PostprocessorName & l_value,
1509 const int & r_value)
1510{
1511 // Assign the default value so that it appears in the dump
1512 std::ostringstream oss;
1513 oss << r_value;
1514 l_value = oss.str();
1515}
1516
1517template <>
1518void
1519InputParameters::setParamHelper<FunctionName, Real>(const std::string & /*name*/,
1520 FunctionName & l_value,
1521 const Real & r_value)
1522{
1523 // Assign the default value so that it appears in the dump
1524 std::ostringstream oss;
1525 oss << r_value;
1526 l_value = oss.str();
1527}
1528
1529template <>
1530void
1531InputParameters::setParamHelper<FunctionName, int>(const std::string & /*name*/,
1532 FunctionName & l_value,
1533 const int & r_value)
1534{
1535 // Assign the default value so that it appears in the dump
1536 std::ostringstream oss;
1537 oss << r_value;
1538 l_value = oss.str();
1539}
1540
1541template <>
1542void
1543InputParameters::setParamHelper<MaterialPropertyName, Real>(const std::string & /*name*/,
1544 MaterialPropertyName & l_value,
1545 const Real & r_value)
1546{
1547 // Assign the default value so that it appears in the dump
1548 std::ostringstream oss;
1549 oss << r_value;
1550 l_value = oss.str();
1551}
1552
1553template <>
1554void
1555InputParameters::setParamHelper<MaterialPropertyName, int>(const std::string & /*name*/,
1556 MaterialPropertyName & l_value,
1557 const int & r_value)
1558{
1559 // Assign the default value so that it appears in the dump
1560 std::ostringstream oss;
1561 oss << r_value;
1562 l_value = oss.str();
1563}
1564
1565template <>
1566void
1567InputParameters::setParamHelper<MooseFunctorName, Real>(const std::string & /*name*/,
1568 MooseFunctorName & l_value,
1569 const Real & r_value)
1570{
1571 // Assign the default value so that it appears in the dump
1572 std::ostringstream oss;
1573 oss << r_value;
1574 l_value = oss.str();
1575}
1576
1577template <>
1578void
1579InputParameters::setParamHelper<MooseFunctorName, int>(const std::string & /*name*/,
1580 MooseFunctorName & l_value,
1581 const int & r_value)
1582{
1583 // Assign the default value so that it appears in the dump
1584 std::ostringstream oss;
1585 oss << r_value;
1586 l_value = oss.str();
1587}
1588
1589template <>
1591InputParameters::getParamHelper<MooseEnum>(const std::string & name_in,
1592 const InputParameters & pars)
1593{
1594 const auto & name = pars.checkForRename(name_in);
1595 return pars.get<MooseEnum>(name);
1596}
1597
1598template <>
1600InputParameters::getParamHelper<MultiMooseEnum>(const std::string & name_in,
1601 const InputParameters & pars)
1602{
1603 const auto & name = pars.checkForRename(name_in);
1604 return pars.get<MultiMooseEnum>(name);
1605}
1606
1607void
1608InputParameters::setReservedValues(const std::string & name_in,
1609 const std::set<std::string> & reserved)
1610{
1611 const auto & name = checkForRename(name_in);
1612 _params[name]._reserved_values = reserved;
1613}
1614
1615std::set<std::string>
1616InputParameters::reservedValues(const std::string & name_in) const
1617{
1618 const auto & name = checkForRename(name_in);
1619 auto it = _params.find(name);
1620 if (it == _params.end())
1621 return std::set<std::string>();
1622 return it->second._reserved_values;
1623}
1624
1625std::string
1627{
1628 if (const auto hit_node = getHitNode())
1629 return hit_node->fileLocation(/* with_column = */ false);
1630 return "";
1631}
1632
1633std::string
1635{
1636 if (const auto hit_node = getHitNode())
1637 return hit_node->fullpath();
1638 return "";
1639}
1640
1641const hit::Node *
1642InputParameters::getHitNode(const std::string & param) const
1643{
1644 return at(param)._hit_node;
1645}
1646
1647void
1648InputParameters::setHitNode(const std::string & param,
1649 const hit::Node & node,
1651{
1652 mooseAssert(node.type() == hit::NodeType::Field, "Must be a field");
1653 at(param)._hit_node = &node;
1654}
1655
1656std::string
1657InputParameters::inputLocation(const std::string & param) const
1658{
1659 if (const auto hit_node = getHitNode(param))
1660 return hit_node->fileLocation(/* with_column = */ false);
1661 return "";
1662}
1663
1664std::string
1665InputParameters::paramFullpath(const std::string & param) const
1666{
1667 if (const auto hit_node = getHitNode(param))
1668 return hit_node->fullpath();
1669 return "";
1670}
1671
1672void
1673InputParameters::checkParamName(const std::string & name) const
1674{
1675 const static pcrecpp::RE valid("[\\w:/]+");
1676 if (!valid.FullMatch(name))
1677 mooseError("Invalid parameter name: '", name, "'");
1678}
1679
1680bool
1681InputParameters::shouldIgnore(const std::string & name_in)
1682{
1683 const auto & name = checkForRename(name_in);
1684 auto it = _params.find(name);
1685 if (it != _params.end())
1686 return it->second._ignore;
1687 mooseError("Parameter ", name, " does not exist");
1688}
1689
1690std::set<std::string>
1691InputParameters::getGroupParameters(const std::string & group) const
1692{
1693 std::set<std::string> names;
1694 for (auto it = _params.begin(); it != _params.end(); ++it)
1695 if (it->second._group == group)
1696 names.emplace(it->first);
1697 return names;
1698}
1699
1700std::set<std::string>
1702{
1703 std::set<std::string> param_set;
1704 for (auto it = _params.begin(); it != _params.end(); ++it)
1705 param_set.emplace(it->first);
1706 return param_set;
1707}
1708
1709std::set<std::string>
1711{
1712 std::set<std::string> controllable;
1713 for (auto it = _params.begin(); it != _params.end(); ++it)
1714 if (it->second._controllable)
1715 controllable.emplace(it->first);
1716 return controllable;
1717}
1718
1719std::string
1720InputParameters::paramLocationPrefix(const std::string & param) const
1721{
1722 auto prefix = param + ":";
1723 if (!inputLocation(param).empty())
1724 prefix = inputLocation(param) + ": (" + paramFullpath(param) + ")";
1725 return prefix;
1726}
1727
1728std::string
1729InputParameters::rawParamVal(const std::string & param) const
1730{
1731 if (const auto hit_node = getHitNode(param))
1732 return hit_node->strVal();
1733 return "";
1734}
1735
1736std::string
1737InputParameters::varName(const std::string & var_param_name,
1738 const std::string & moose_object_with_var_param_name) const
1739{
1740 // Try the scalar version first
1741 std::string variable_name = getMooseType(var_param_name);
1742 if (variable_name == "")
1743 {
1744 auto vec = getVecMooseType(var_param_name);
1745
1746 // Catch the (very unlikely) case where a user specifies
1747 // variable = '' (the empty string)
1748 // in their input file. This could happen if e.g. something goes
1749 // wrong with dollar bracket expression expansion.
1750 if (vec.empty())
1751 mooseError("Error constructing object '",
1752 moose_object_with_var_param_name,
1753 "' while retrieving value for '",
1754 var_param_name,
1755 "' parameter! Did you forget to set '",
1756 var_param_name,
1757 "' or set it to '' (empty string) by accident?");
1758
1759 // When using vector variables, we are only going to use the first one in the list at the
1760 // interface level...
1761 variable_name = vec[0];
1762 }
1763
1764 return variable_name;
1765}
1766
1767void
1768InputParameters::renameParamInternal(const std::string & old_name,
1769 const std::string & new_name,
1770 const std::string & docstring,
1771 const std::string & removal_date)
1772{
1773 auto params_it = _params.find(old_name);
1774 if (params_it == _params.end())
1775 mooseError("Requested to rename parameter '",
1776 old_name,
1777 "' but that parameter name doesn't exist in the parameters object.");
1778 mooseAssert(params_it->second._deprecation_message.empty(),
1779 "Attempting to rename the parameter, '" << old_name << "', that is deprecated");
1780
1781 auto new_metadata = std::move(params_it->second);
1782 if (!docstring.empty())
1783 new_metadata._doc_string = docstring;
1784 _params.emplace(new_name, std::move(new_metadata));
1785 _params.erase(params_it);
1786
1787 auto values_it = _values.find(old_name);
1788 auto new_value = std::move(values_it->second);
1789 _values.emplace(new_name, std::move(new_value));
1790 _values.erase(values_it);
1791
1792 std::string deprecation_message;
1793 if (!removal_date.empty())
1794 deprecation_message = "'" + old_name + "' has been deprecated and will be removed on " +
1795 removal_date + ". Please use '" + new_name + "' instead.";
1796
1797 _old_to_new_name_and_dep.emplace(old_name, std::make_pair(new_name, deprecation_message));
1798 _new_to_old_names.emplace(new_name, old_name);
1799}
1800
1801void
1803 const std::string & new_name,
1804 const std::string & docstring,
1805 const std::string & removal_date)
1806{
1807 auto coupled_vars_it = _coupled_vars.find(old_name);
1808 if (coupled_vars_it == _coupled_vars.end())
1809 mooseError("Requested to rename coupled variable '",
1810 old_name,
1811 "' but that coupled variable name doesn't exist in the parameters object.");
1812
1813 _coupled_vars.insert(new_name);
1814 _coupled_vars.erase(coupled_vars_it);
1815
1816 renameParamInternal(old_name, new_name, docstring, removal_date);
1817}
1818
1819void
1820InputParameters::renameParam(const std::string & old_name,
1821 const std::string & new_name,
1822 const std::string & new_docstring)
1823{
1824 renameParamInternal(old_name, new_name, new_docstring, "");
1825}
1826
1827void
1828InputParameters::renameCoupledVar(const std::string & old_name,
1829 const std::string & new_name,
1830 const std::string & new_docstring)
1831{
1832 renameCoupledVarInternal(old_name, new_name, new_docstring, "");
1833}
1834
1835void
1836InputParameters::deprecateParam(const std::string & old_name,
1837 const std::string & new_name,
1838 const std::string & removal_date)
1839{
1840 renameParamInternal(old_name, new_name, "", removal_date);
1841}
1842
1843void
1844InputParameters::deprecateCoupledVar(const std::string & old_name,
1845 const std::string & new_name,
1846 const std::string & removal_date)
1847{
1848 renameCoupledVarInternal(old_name, new_name, "", removal_date);
1849}
1850
1851const std::string &
1852InputParameters::checkForRename(const std::string & name) const
1853{
1854 if (auto it = _old_to_new_name_and_dep.find(name); it != _old_to_new_name_and_dep.end())
1855 return it->second.first;
1856 else
1857 return name;
1858}
1859
1860std::vector<std::string>
1861InputParameters::paramAliases(const std::string & param_name) const
1862{
1863 mooseAssert(_values.find(param_name) != _values.end(),
1864 "The parameter we are searching for aliases for should exist in our parameter map");
1865 std::vector<std::string> aliases = {param_name};
1866
1867 for (const auto & pr : as_range(_new_to_old_names.equal_range(param_name)))
1868 aliases.push_back(pr.second);
1869
1870 return aliases;
1871}
1872
1873std::optional<Moose::DataFileUtils::Path>
1874InputParameters::queryDataFileNamePath(const std::string & name) const
1875{
1877}
1878
1879std::optional<std::string>
1880InputParameters::setupVariableNames(std::vector<VariableName> & names,
1881 const hit::Node & node,
1883{
1884 // Whether or not a name was found
1885 bool has_name = false;
1886 // Whether or not a default value (real) was found
1887 bool has_default = false;
1888
1889 // Search through the names for values that convert to Real values,
1890 // which are default values. If defaults are found, set appropriately
1891 // in the InputParameters object. Keep track of if names or defaults
1892 // were found because we don't allow having both
1893 for (const auto i : index_range(names))
1894 {
1895 auto & name = names[i];
1896 Real real_value;
1897 if (MooseUtils::convert<Real>(name, real_value, false))
1898 {
1899 has_default = true;
1900 defaultCoupledValue(node.path(), real_value, i);
1901 }
1902 else
1903 has_name = true;
1904 }
1905
1906 if (has_default)
1907 {
1908 if (has_name)
1909 return {"invalid value for '" + node.fullpath() +
1910 "': coupled vectors where some parameters are reals and others are variables are not "
1911 "supported"};
1912
1913 // Don't actually use the names if these don't represent names
1914 names.clear();
1915 }
1916
1917 return {};
1918}
1919
1920std::pair<std::string, const hit::Node *>
1921InputParameters::paramMessageContext(const std::string & param) const
1922{
1923 const hit::Node * node = nullptr;
1924
1925 std::string fullpath;
1926 // First try to find the parameter
1927 if (const hit::Node * param_node = getHitNode(param))
1928 {
1929 fullpath = param_node->fullpath();
1930 node = param_node;
1931 }
1932 // If no parameter node, hope for a block node
1933 else if (const hit::Node * block_node = getHitNode())
1934 {
1935 node = block_node;
1936 fullpath = block_node->fullpath() + "/" + param;
1937 }
1938 // Didn't find anything, at least use the parameter
1939 else
1940 fullpath = param;
1941
1942 return {fullpath + ": ", node};
1943}
1944
1945std::string
1946InputParameters::paramMessagePrefix(const std::string & param) const
1947{
1948 auto [prefix, node] = paramMessageContext(param);
1949 if (node)
1950 prefix = Moose::hitMessagePrefix(*node) + prefix;
1951 return prefix;
1952}
1953
1954[[noreturn]] void
1956 const bool with_prefix /* = true */,
1957 const hit::Node * node /* = nullptr */,
1958 const bool show_trace /* = true */) const
1959{
1960 // Find the context of the app if we can. This will let our errors be
1961 // prefixed by the multiapp name (if applicable) and will flush the
1962 // console before outputting an error
1963 MooseApp * app = nullptr;
1964 if (isMooseBaseObject() && have_parameter<MooseApp *>(MooseBase::app_param))
1965 app = get<MooseApp *>(MooseBase::app_param);
1966
1967 MooseBase::callMooseError(app, *this, msg, with_prefix, node, show_trace);
1968}
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...
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:898
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.