53 const std::string &
cname()
const;
127 template <
typename T>
135 template <
typename T>
144 template <
typename T>
153 template <
typename T>
168 const std::string & obj_name,
169 const std::string & param)
const;
182 const std::string & obj_name,
183 const std::string & comp_param,
184 const std::string & obj_param)
const;
210 template <
typename T>
219 template <
typename T>
225 template <
typename... Args>
234 template <
typename... Args>
258 template <
typename T>
259 T getEnumParam(
const std::string & param,
bool log_error =
true)
const;
269 const std::vector<dof_id_type> &
getNodeIDs()
const;
288 virtual const std::vector<Moose::CoordinateSystemType> &
getCoordSysTypes()
const;
301 template <
typename T>
303 const std::string & param_name)
const;
312 template <
typename T>
322 template <
typename T>
323 void checkSizeLessThan(
const std::string & param,
const unsigned int & n_entries)
const;
332 template <
typename T>
343 template <
typename T1,
typename T2>
344 void checkEqualSize(
const std::string & param1,
const std::string & param2)
const;
355 template <
typename T>
368 template <
typename T>
370 const unsigned int & n_entries,
371 const std::string & description)
const;
381 template <
typename T1,
typename T2>
391 bool need_one_specified =
true)
const;
434 Node *
addNode(
const Point & pt);
446 const std::string & subdomain_name,
458 const std::string & property,
470 const std::string & pp_name,
471 const Real normalization,
472 const std::vector<SubdomainName> & subdomains);
482 const std::vector<std::string> & descriptions,
483 const std::vector<Real> & tolerances);
559 const std::string & comp_name = getParam<std::string>(pname);
560 return getComponentByName<T>(comp_name);
574 const std::string & comp_name = getParam<std::string>(pname);
575 return hasComponentByName<T>(comp_name);
592 const MooseEnum & moose_enum = getParam<MooseEnum>(param);
593 const T value = THM::stringToEnum<T>(moose_enum);
594 if (log_error &&
static_cast<int>(value) < 0)
599 const std::vector<std::string> & keys = moose_enum.
getNames();
603 std::string keys_string =
"{";
604 for (
unsigned int i = 0; i < keys.size() - 1; ++i)
608 keys_string +=
"'" + keys[i] +
"'";
612 logError(
"The parameter '" + param +
"' was given an invalid value ('" +
613 std::string(moose_enum) +
"'). Valid values (case-insensitive) are " + keys_string);
622 const std::string & param_name)
const
624 if (!hasParam<T>(param_name))
628 " failed, parameter '",
630 "' does not exist or does not have the type you requested. Double check your "
631 "spelling and/or type of the parameter.");
638 insistParameterExists<std::string>(__FUNCTION__, param);
640 const std::string & comp_name = getParam<std::string>(param);
641 checkComponentOfTypeExistsByName<T>(comp_name);
651 logError(
"The component '", comp_name,
"' is not of type '", demangle(
typeid(
T).
name()),
"'");
653 logError(
"The component '", comp_name,
"' does not exist");
661 insistParameterExists<T>(__FUNCTION__, param);
663 const auto & value = getParam<T>(param);
664 if (value >= value_max)
665 logError(
"The value of parameter '", param,
"' (", value,
") must be less than ", value_max);
672 insistParameterExists<std::vector<T>>(__FUNCTION__, param);
674 const auto & value = getParam<std::vector<T>>(param);
675 if (value.size() >= n_entries)
676 logError(
"The number of entries in the parameter '",
680 ") must be less than ",
688 insistParameterExists<std::vector<T>>(__FUNCTION__, param);
690 const auto & value = getParam<std::vector<T>>(param);
691 if (value.size() <= n_entries)
692 logError(
"The number of entries in the parameter '",
696 ") must be greater than ",
700template <
typename T1,
typename T2>
704 insistParameterExists<std::vector<T1>>(__FUNCTION__, param1);
705 insistParameterExists<std::vector<T2>>(__FUNCTION__, param2);
707 const auto & value1 = getParam<std::vector<T1>>(param1);
708 const auto & value2 = getParam<std::vector<T2>>(param2);
709 if (value1.size() != value2.size())
710 logError(
"The number of entries in parameter '",
714 ") must equal the number of entries of parameter '",
725 insistParameterExists<std::vector<T>>(__FUNCTION__, param);
727 const auto & param_value = getParam<std::vector<T>>(param);
728 if (param_value.size() != n_entries)
729 logError(
"The number of entries in parameter '",
733 ") must be equal to ",
740 const unsigned int & n_entries,
741 const std::string & description)
const
743 insistParameterExists<std::vector<T>>(__FUNCTION__, param);
745 const auto & param_value = getParam<std::vector<T>>(param);
746 if (param_value.size() != n_entries)
747 logError(
"The number of entries in parameter '",
751 ") must be equal to ",
758template <
typename T1,
typename T2>
761 const std::string & param2)
const
763 insistParameterExists<std::vector<T1>>(__FUNCTION__, param1);
764 insistParameterExists<T2>(__FUNCTION__, param2);
766 const auto & value1 = getParam<std::vector<T1>>(param1);
767 const auto & value2 = getParam<T2>(param2);
768 if (value1.size() != value2)
769 logError(
"The number of entries in parameter '",
773 ") must be equal to the value of parameter '",
Base class for THM components.
std::string stringify(EComponentSetupStatus status) const
Return a string for the setup status.
virtual void addMooseObjects()
const THMMesh & constMesh() const
Const reference to mesh, which can be called at any point.
virtual void init()
Initializes the component.
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
void logError(Args &&... args) const
Logs an error.
const std::vector< dof_id_type > & getElementIDs() const
Gets the element IDs corresponding to this component.
Elem * addNodeElement(dof_id_type node)
void addDependency(const std::string &dependency)
Adds a component name to the list of dependencies.
bool hasParam(const std::string &name) const
Test if a parameter exists in the object's input parameters.
void addMaximumFunctorPostprocessor(const std::string &functor_name, const std::string &pp_name, const Real normalization, const std::vector< SubdomainName > &subdomains)
Adds a Postprocessor to compute the maximum of a functor over some domain.
virtual const std::vector< Moose::CoordinateSystemType > & getCoordSysTypes() const
Gets the coordinate system types for this component.
bool hasComponentByName(const std::string &cname) const
Check the existence and type of a component given its name.
void executeInit()
Wrapper function for init() that marks the function as being called.
void insistParameterExists(const std::string &function_name, const std::string ¶m_name) const
Runtime check to make sure that a parameter of specified type exists in the component's input paramet...
THMProblem & getTHMProblem() const
Gets the THM problem.
Factory & _factory
The Factory associated with the MooseApp.
std::string nonlinearConvergenceName() const
Nonlinear Convergence name.
void addNonlinearStepFunctorMaterial(const std::string &functor_name, const std::string &property, bool functor_is_ad)
Adds a functor material to compute the absolute value of the change (step) of some functor between no...
virtual void check() const
Check the component integrity.
std::vector< dof_id_type > _elem_ids
Element IDs of this component.
void checkSizeEqualsValue(const std::string ¶m, const unsigned int &n_entries) const
Checks that the size of a vector parameter equals a value.
Node * addNode(const Point &pt)
virtual void setSubdomainInfo(SubdomainID subdomain_id, const std::string &subdomain_name, const Moose::CoordinateSystemType &coord_system=Moose::COORD_XYZ)
Sets the next subdomain ID, name, and coordinate system.
void checkComponentOfTypeExists(const std::string ¶m) const
Checks that the component of a certain type exists, where the name is given by a parameter.
void checkSizeEqualsParameterValue(const std::string ¶m1, const std::string ¶m2) const
Checks that the size of a vector parameter equals the value of another parameter.
void addRelationshipManagersFromParameters(const InputParameters &moose_object_pars)
Method to add a relationship manager for the objects being added to the system.
void checkComponentExistsByName(const std::string &comp_name) const
Checks that a component exists.
const std::vector< std::string > & getDependencies() const
Returns a list of names of components that this component depends upon.
bool problemIsTransient() const
Whether the problem is transient.
virtual Convergence * getNonlinearConvergence() const
Gets the Component's nonlinear Convergence object if it has one.
std::vector< SubdomainID > _subdomain_ids
List of subdomain IDs this components owns.
EComponentSetupStatus
Component setup status type.
@ CHECKED
mesh set up, called both inits, checked
@ MESH_PREPARED
mesh set up
@ INITIALIZED_PRIMARY
mesh set up, called primary init
@ INITIALIZED_SECONDARY
mesh set up, called both inits
std::vector< Moose::CoordinateSystemType > _coord_sys
List of coordinate system for each subdomain.
void checkEqualSize(const std::string ¶m1, const std::string ¶m2) const
Checks that the size of two vector parameters are equal.
THMProblem & _sim
THM problem this component is part of TODO: make _sim private (applications need to switch to getters...
virtual void setupMesh()
Performs mesh setup such as creating mesh or naming mesh sets.
void executeInitSecondary()
Wrapper function for initSecondary() that marks the function as being called.
virtual void addVariables()
void addMultiPostprocessorConvergence(const std::vector< PostprocessorName > &postprocessors, const std::vector< std::string > &descriptions, const std::vector< Real > &tolerances)
Adds a MultiPostprocessorConvergence for nonlinear convergence for the component.
EComponentSetupStatus _component_setup_status
Component setup status.
std::vector< dof_id_type > _node_ids
Node IDs of this component.
std::vector< SubdomainName > _subdomain_names
List of subdomain names this components owns.
const T & getComponent(const std::string &name) const
Return a reference to a component via a parameter name.
void executeCheck() const
Wrapper function for check() that marks the function as being called.
void checkSizeLessThan(const std::string ¶m, const unsigned int &n_entries) const
Checks that the size of a vector parameter is less than a value.
const T & getComponentByName(const std::string &cname) const
Return a reference to a component given its name.
void checkParameterValueLessThan(const std::string ¶m, const T &value_max) const
Checks that a parameter value is less than a value.
bool hasComponent(const std::string &name) const
Check the existence and type of a component via a parameter name.
virtual void initSecondary()
Perform secondary initialization, which relies on init() being called for all components.
const std::string & cname() const
Get the component name.
T getEnumParam(const std::string ¶m, bool log_error=true) const
Gets an enum parameter.
void connectObject(const InputParameters &obj_params, const std::string &obj_name, const std::string ¶m) const
Connects a controllable parameter of the component to a controllable parameter of a constituent objec...
void checkSetupStatus(const EComponentSetupStatus &status) const
Throws an error if the supplied setup status of this component has not been reached.
void checkSizeGreaterThan(const std::string ¶m, const unsigned int &n_entries) const
Checks that the size of a vector parameter is greater than a value.
THMMesh & mesh()
Non-const reference to THM mesh, which can only be called before the end of mesh setup.
std::vector< std::string > _dependencies
List of names of components that this component depends upon.
void checkMutuallyExclusiveParameters(const std::vector< std::string > ¶ms, bool need_one_specified=true) const
Checks that exactly one parameter out of a list is provided.
const std::vector< dof_id_type > & getNodeIDs() const
Gets the node IDs corresponding to this component.
THMMesh & _mesh
The THM mesh TODO: make _mesh private (applications need to switch to getters to avoid breaking)
void executeSetupMesh()
Wrapper function for setupMesh() that marks the function as being called.
Component * _parent
Pointer to a parent component (used in composed components)
void checkComponentOfTypeExistsByName(const std::string &comp_name) const
Checks that the component of a certain type exists.
void logWarning(Args &&... args) const
Logs a warning.
virtual void addRelationshipManagers(Moose::RelationshipManagerType)
Adds relationship managers for the component.
void addRelationshipManager(const InputParameters &moose_object_pars, std::string rm_name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback rm_input_parameter_func, Moose::RMSystemType sys_type=Moose::RMSystemType::NONE)
Method for adding a single relationship manager.
static InputParameters validParams()
virtual bool isTransient() const override
Interface class for logging errors and warnings.
void logComponentWarning(const std::string &component_name, Args &&... args) const
Logs a warning for a component.
void logComponentError(const std::string &component_name, Args &&... args) const
Logs an error for a component.
const InputParameters & parameters() const
const std::string & name() const
void mooseError(Args &&... args) const
std::vector< std::string > getNames() const
Interface for handling names.
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
const T & getComponentByName(const std::string &name) const
Get component by its name.
bool hasComponentOfType(const std::string &name) const
Find out if simulation has a component with the given name and specified type.
bool hasComponent(const std::string &name) const
Find out if simulation has a component with the given name.
Specialization of FEProblem to run with component subsystem.
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback