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";
328 const std::vector<dof_id_type> &
336 const std::vector<dof_id_type> &
344 const std::vector<SubdomainName> &
352 const std::vector<Moose::CoordinateSystemType> &
363 mooseError(
"getNonlinearConvergence() not implemented.");
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 executeCheck() const
Wrapper function for check() that marks the function as being called.
Specialization of FEProblem to run with component subsystem.
Interface for handling names.
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.
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 ExecFlagType EXEC_NONLINEAR_CONVERGENCE
THMProblem & _sim
THM problem this component is part of TODO: make _sim private (applications need to switch to getters...
EComponentSetupStatus
Component setup status type.
virtual void setupMesh()
Performs mesh setup such as creating mesh or naming mesh sets.
THMProblem & getTHMProblem() const
Gets the THM problem.
InputParameterWarehouse & getInputParameterWarehouse()
void addDependency(const std::string &dependency)
Adds a component name to the list of dependencies.
const std::vector< dof_id_type > & getElementIDs() const
Gets the element IDs corresponding to this component.
std::vector< SubdomainName > _subdomain_names
List of subdomain names this components owns.
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)
static InputParameters validParams()
InputParameters getValidParams(const std::string &name) const
const std::string & cname() const
Get the component name.
virtual void addFunctorMaterial(const std::string &functor_material_name, const std::string &name, InputParameters ¶meters)
Component * _parent
Pointer to a parent component (used in composed components)
std::string stringify(EComponentSetupStatus status) const
Return a string for the setup status.
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.
Interface class for logging errors and warnings.
Node * addNode(const Point &pt)
static InputParameters validParams()
Elem * addNodeElement(dof_id_type node)
std::vector< Moose::CoordinateSystemType > _coord_sys
List of coordinate system for each subdomain.
std::vector< dof_id_type > _elem_ids
Element IDs of this component.
void logError(Args &&... args) const
Logs an error.
Elem * addNodeElement(dof_id_type node)
virtual void check() const
Check the component integrity.
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters ¶meters)
bool hasComponent(const std::string &name) const
Find out if simulation has a component with the given name.
const std::string & name() const
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
virtual void addConvergence(const std::string &type, const std::string &name, InputParameters ¶meters)
Component(const InputParameters ¶meters)
void setSubdomainName(SubdomainID subdomain_id, const SubdomainName &name)
std::function< void(const InputParameters &, InputParameters &)> RelationshipManagerInputParameterCallback
std::vector< dof_id_type > _node_ids
Node IDs of this component.
void checkComponentExistsByName(const std::string &comp_name) const
Checks that a component exists.
std::string nonlinearConvergenceName() const
Nonlinear Convergence name.
mesh set up, called primary init
mesh set up, called both inits
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. ...
virtual void init()
Initializes the component.
Base class for THM components.
std::string stringify(const T &t)
virtual const std::vector< Moose::CoordinateSystemType > & getCoordSysTypes() const
Gets the coordinate system types for this component.
virtual void initSecondary()
Perform secondary initialization, which relies on init() being called for all components.
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
THMMesh & mesh()
Non-const reference to THM mesh, which can only be called before the end of mesh setup.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.
EComponentSetupStatus _component_setup_status
Component setup status.
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...
std::vector< std::string > _dependencies
List of names of components that this component depends upon.
void checkSetupStatus(const EComponentSetupStatus &status) const
Throws an error if the supplied setup status of this component has not been reached.
std::vector< SubdomainID > _subdomain_ids
List of subdomain IDs this components owns.
Factory & _factory
The Factory associated with the MooseApp.
void mooseError(Args &&... args) const
virtual Convergence * getNonlinearConvergence() const
Gets the Component's nonlinear Convergence object if it has one.
bool isParamValid(const std::string &name) const
mesh set up, called both inits, checked
void addRelationshipManagersFromParameters(const InputParameters &moose_object_pars)
Method to add a relationship manager for the objects being added to the system.
THMMesh & _mesh
The THM mesh TODO: make _mesh private (applications need to switch to getters to avoid breaking) ...
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
static InputParameters validParams()
void executeInit()
Wrapper function for init() that marks the function as being called.
void executeSetupMesh()
Wrapper function for setupMesh() that marks the function as being called.
const std::vector< dof_id_type > & getNodeIDs() const
Gets the node IDs corresponding to this component.
void executeInitSecondary()
Wrapper function for initSecondary() that marks the function as being called.
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.
Node * addNode(const Point &pt)
Add a new node into the mesh.