https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PhysicsComponentInterface.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
12
15{
17 // we likely do not need all these parameters. But developers could expect them
18 return params;
19}
20
22 : PhysicsBase(parameters)
23{
24 // Temporarily not required until TMAP8 physics are updated to use new task
25 // addRequiredPhysicsTask("add_ic");
26}
27
28void
30{
31 // TODO: find a way to force this routine to be called by derived classes
32 // TODO: only keep the ics_physics task to prevent the risk of calling this twice
33 if ((_current_task == "add_ic" || _current_task == "add_ics_physics"))
35 else if (_current_task == "add_bc" || _current_task == "add_fv_bc")
37}
38
39void
41{
42 // Adds the component's blocks to the block restriction at least
44
45 // Move initial conditions from components to the Physics
46 if (const auto comp_ic = dynamic_cast<const ComponentInitialConditionInterface *>(&comp))
47 {
48 for (const auto & var_name : solverVariableNames())
49 if (comp_ic->hasInitialCondition(var_name))
50 addInitialCondition(comp.name(), var_name, comp_ic->getInitialCondition(var_name, name()));
51 for (const auto & var_name : auxVariableNames())
52 if (comp_ic->hasInitialCondition(var_name))
53 addInitialCondition(comp.name(), var_name, comp_ic->getInitialCondition(var_name, name()));
54 }
55
56 // Move boundary conditions from components to the Physics
57 if (const auto comp_bc = dynamic_cast<const ComponentBoundaryConditionInterface *>(&comp))
58 {
59 for (const auto & var_name : solverVariableNames())
60 if (comp_bc->hasBoundaryCondition(var_name))
61 for (const auto & boundary : comp_bc->getBoundaryConditionBoundaries(var_name))
62 {
64 const auto boundary_functor =
65 comp_bc->getBoundaryCondition(var_name, boundary, name(), bc_type);
66 addBoundaryCondition(comp.name(), var_name, boundary, boundary_functor, bc_type);
67 }
68 for (const auto & var_name : auxVariableNames())
69 if (comp_bc->hasBoundaryCondition(var_name))
70 for (const auto & boundary : comp_bc->getBoundaryConditionBoundaries(var_name))
71 {
73 const auto boundary_functor =
74 comp_bc->getBoundaryCondition(var_name, boundary, name(), bc_type);
75 addBoundaryCondition(comp.name(), var_name, boundary, boundary_functor, bc_type);
76 }
77 }
78}
79
80void
81PhysicsComponentInterface::addInitialCondition(const ComponentName & component_name,
82 const VariableName & var_name,
83 const MooseFunctorName & ic_value)
84{
85 _components_initial_conditions[component_name][var_name] = ic_value;
86}
87
88void
90 const ComponentName & component_name,
91 const VariableName & var_name,
92 const BoundaryName & boundary_name,
93 const MooseFunctorName & bc_value,
95{
96 _components_boundary_conditions[component_name][std::make_pair(var_name, boundary_name)] =
97 std::make_pair(bc_value, bc_type);
98}
99
100void
102{
104 {
105 std::vector<ComponentName> all_components(_components_initial_conditions.size());
106 for (const auto & comp : _components_initial_conditions)
107 all_components.push_back(comp.first);
108 mooseError("Component(s) '",
109 Moose::stringify(all_components),
110 "' requested to add the following initial conditions for this Physics. This Physics "
111 "however does not implement the 'addInitialConditionsFromComponents' "
112 "routine, so it cannot create these initial conditions");
113 }
114}
115
116void
118{
120 {
121 std::vector<ComponentName> all_components(_components_boundary_conditions.size());
122 for (const auto & comp : _components_boundary_conditions)
123 all_components.push_back(comp.first);
124 mooseError("Component(s) '",
125 Moose::stringify(all_components),
126 "' requested to add boundary conditions for the variable of this Physics. This "
127 "Physics however does not implement the 'addBoundaryConditionsFromComponents' "
128 "routine, so it cannot create these boundary conditions");
129 }
130}
Base class for components that are defined using an action.
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition Action.h:172
Helper class to help Components accept boundary condition parameters that the Physics may use to gene...
Helper class to help Components define the initial conditions the Physics may need from the parameter...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
Base class to help creating an entire physics.
Definition PhysicsBase.h:31
const std::vector< VariableName > & auxVariableNames() const
Return the list of aux variables in this physics.
static InputParameters validParams()
Definition PhysicsBase.C:24
const std::vector< VariableName > & solverVariableNames() const
Return the list of solver (nonlinear + linear) variables in this physics.
virtual void addComponent(const ActionComponent &component)
Most basic way of adding a component: simply adding the blocks to the block restriction of the Physic...
std::map< std::string, std::map< VariableName, MooseFunctorName > > _components_initial_conditions
Map of components to variables and initial conditions.
std::map< std::string, std::map< std::pair< VariableName, BoundaryName >, std::pair< MooseFunctorName, ComponentBoundaryConditionInterface::BoundaryConditionType > > > _components_boundary_conditions
Map of components to variables and boundary conditions.
virtual void addComponent(const ActionComponent &component) override
Adds various info from the component.
static InputParameters validParams()
void addInitialCondition(const ComponentName &component_name, const VariableName &var_name, const MooseFunctorName &ic_value)
Add an initial condition from a component.
void addBoundaryCondition(const ComponentName &component_name, const VariableName &var_name, const BoundaryName &boundary_name, const MooseFunctorName &bc_value, const ComponentBoundaryConditionInterface::BoundaryConditionType &bc_type)
Add a boundary condition from a component.
virtual void actOnAdditionalTasks() override
Routine to add additional setup work on additional registered tasks to a Physics.
PhysicsComponentInterface(const InputParameters &parameters)
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64