24 params.
addPrivateParam<std::string>(
"built_by_action",
"add_component");
41 _parent(getParam<
Component *>(
"_parent")),
42 _sim(*getCheckedPointerParam<
THMProblem *>(
"_thm_problem")),
43 _factory(_app.getFactory()),
44 _zero(_sim._real_zero[0]),
46 _component_setup_status(CREATED)
64 "A non-const reference to the THM mesh cannot be obtained after mesh setup is complete.");
99 const std::string & obj_name,
100 const std::string & param)
const
107 const std::string & obj_name,
108 const std::string & comp_param,
109 const std::string & obj_param)
const
121 ": The component setup status (",
123 ") is less than the required status (",
144 logError(
"The component '", comp_name,
"' does not exist");
152 for (
const auto & buildable_type : buildable_types)
154 auto & rm_name = std::get<0>(buildable_type);
155 auto & rm_type = std::get<1>(buildable_type);
156 auto rm_input_parameter_func = std::get<2>(buildable_type);
171 static unsigned int unique_object_id = 0;
173 auto new_name = moose_object_pars.
getBase() +
'_' +
name() +
'_' + rm_name +
"_" +
179 rm_params.set<std::string>(
"for_whom") =
name();
182 if (rm_input_parameter_func)
183 rm_input_parameter_func(moose_object_pars, rm_params);
187 if (!rm_params.areAllRequiredParamsValid())
188 mooseError(
"Missing required parameters for RelationshipManager " + rm_name +
" for object " +
220 const std::string & subdomain_name,
237 const std::string & property,
240 const std::string class_name =
241 functor_is_ad ?
"ADFunctorChangeFunctorMaterial" :
"FunctorChangeFunctorMaterial";
244 params.
set<MooseFunctorName>(
"functor") = functor_name;
246 params.
set<std::string>(
"prop_name") = property;
247 params.
set<
bool>(
"take_absolute_value") =
true;
253 const std::string & pp_name,
254 const Real normalization,
255 const std::vector<SubdomainName> & subdomains)
257 const std::string class_name =
"ElementExtremeFunctorValue";
259 params.
set<std::vector<SubdomainName>>(
"block") = subdomains;
261 params.
set<MooseFunctorName>(
"functor") = functor_name;
262 params.
set<Real>(
"scale") = 1.0 / normalization;
264 params.
set<std::vector<OutputName>>(
"outputs") = {
"none"};
270 const std::vector<std::string> & descriptions,
271 const std::vector<Real> & tolerances)
273 const std::string class_name =
"MultiPostprocessorConvergence";
275 params.
set<std::vector<PostprocessorName>>(
"postprocessors") = postprocessors;
276 params.
set<std::vector<std::string>>(
"descriptions") = descriptions;
277 params.
set<std::vector<Real>>(
"tolerances") = tolerances;
278 params.
set<
unsigned int>(
"min_iterations") = 1;
279 params.
set<
unsigned int>(
"max_iterations") = std::numeric_limits<unsigned int>::max();
285 bool need_one_specified)
const
287 unsigned int n_provided_params = 0;
288 for (
const auto & param : params)
292 if (n_provided_params != 1)
294 std::string params_list_string =
"{'" + params[0] +
"'";
295 for (
unsigned int i = 1; i < params.size(); ++i)
296 params_list_string +=
", '" + params[i] +
"'";
297 params_list_string +=
"}";
299 if (n_provided_params == 0 && need_one_specified)
300 logError(
"One of the parameters ", params_list_string,
" must be provided");
302 if (n_provided_params != 0)
303 logError(
"Only one of the parameters ", params_list_string,
" can be provided");
314 return "component created";
316 return "component mesh set up";
318 return "primary initialization completed";
320 return "secondary initialization completed";
322 return "component fully set up and checked";
328const std::vector<dof_id_type> &
336const std::vector<dof_id_type> &
344const std::vector<SubdomainName> &
352const std::vector<Moose::CoordinateSystemType> &
363 mooseError(
"getNonlinearConvergence() not implemented.");
const ExecFlagType EXEC_NONLINEAR_CONVERGENCE
static InputParameters validParams()
Base class for THM components.
std::string stringify(EComponentSetupStatus status) const
Return a string for the setup status.
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.
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.
void executeInit()
Wrapper function for init() that marks the function as being called.
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.
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 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.
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.
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.
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.
void executeCheck() const
Wrapper function for check() that marks the function as being called.
virtual void initSecondary()
Perform secondary initialization, which relies on init() being called for all components.
const std::string & cname() const
Get the component name.
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.
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)
Component(const InputParameters ¶meters)
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 void addConvergence(const std::string &type, const std::string &name, InputParameters ¶meters)
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters ¶meters)
virtual void addFunctorMaterial(const std::string &functor_material_name, const std::string &name, InputParameters ¶meters)
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
InputParameters getValidParams(const std::string &name) const
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
Interface class for logging errors and warnings.
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
InputParameterWarehouse & getInputParameterWarehouse()
const std::string & name() const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
void setSubdomainName(SubdomainID subdomain_id, const SubdomainName &name)
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.
bool hasComponent(const std::string &name) const
Find out if simulation has a component with the given name.
Elem * addNodeElement(dof_id_type node)
Node * addNode(const Point &pt)
Add a new node into the mesh.
static InputParameters validParams()
Specialization of FEProblem to run with component subsystem.
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
std::string stringify(const T &t)