18 params.addParam<std::vector<VariableName>>(
19 "fixed_value_bc_variables",
21 "List of variables that have fixed value boundary condition(s) defined on this component");
22 params.addParam<std::vector<std::vector<BoundaryName>>>(
23 "fixed_value_bc_boundaries",
25 "Boundaries on which to apply the fixed value boundary condition(s). Outer ordering is " 26 "variables, inner order is surfaces");
27 params.addParam<std::vector<std::vector<MooseFunctorName>>>(
28 "fixed_value_bc_values",
30 "Functors that provide the fixed value boundary condition(s) values. Outer ordering is " 31 "variables, inner order is surfaces");
33 params.addParam<std::vector<VariableName>>(
36 "List of variables that have flux boundary condition(s) defined on this component");
37 params.addParam<std::vector<std::vector<BoundaryName>>>(
40 "Boundaries on which to apply the flux boundary condition(s). Outer ordering is " 41 "variables, inner order is surfaces");
42 params.addParam<std::vector<std::vector<MooseFunctorName>>>(
45 "Functors that provide the flux boundary condition(s) values. Outer ordering is " 46 "variables, inner order is surfaces");
48 params.addParamNamesToGroup(
49 "fixed_value_bc_variables fixed_value_bc_boundaries fixed_value_bc_values flux_bc_variables " 50 " flux_bc_boundaries flux_bc_values",
51 "Variable boundary conditions");
58 _fixed_value_bc_variables(getParam<
std::vector<VariableName>>(
"fixed_value_bc_variables")),
59 _flux_bc_variables(getParam<
std::vector<VariableName>>(
"flux_bc_variables"))
65 checkVectorParamsNoOverlap<VariableName>({
"fixed_value_bc_variables"});
66 checkVectorParamsNoOverlap<VariableName>({
"flux_bc_variables"});
69 const auto & fixed_value_boundaries =
70 getParam<std::vector<std::vector<BoundaryName>>>(
"fixed_value_bc_boundaries");
71 const auto & fixed_value_values =
72 getParam<std::vector<std::vector<MooseFunctorName>>>(
"fixed_value_bc_values");
73 checkVectorParamsSameLength<VariableName, std::vector<BoundaryName>>(
"fixed_value_bc_variables",
74 "fixed_value_bc_boundaries");
75 checkVectorParamsSameLength<VariableName, std::vector<MooseFunctorName>>(
76 "fixed_value_bc_variables",
"fixed_value_bc_values");
77 checkTwoDVectorParamsSameLength<BoundaryName, MooseFunctorName>(
"fixed_value_bc_boundaries",
78 "fixed_value_bc_values");
79 const auto & flux_boundaries =
80 getParam<std::vector<std::vector<BoundaryName>>>(
"flux_bc_boundaries");
81 const auto & flux_values = getParam<std::vector<std::vector<MooseFunctorName>>>(
"flux_bc_values");
82 checkVectorParamsSameLength<VariableName, std::vector<BoundaryName>>(
"flux_bc_variables",
83 "flux_bc_boundaries");
84 checkVectorParamsSameLength<VariableName, std::vector<MooseFunctorName>>(
"flux_bc_variables",
86 checkTwoDVectorParamsSameLength<BoundaryName, MooseFunctorName>(
"flux_bc_boundaries",
98 for (
const auto j :
index_range(fixed_value_boundaries[i]))
99 _fixed_value_bcs[var_name][fixed_value_boundaries[i][j]] = fixed_value_values[i][j];
104 for (
const auto j :
index_range(flux_boundaries[i]))
105 _flux_bcs[var_name][flux_boundaries[i][j]] = flux_values[i][j];
114 const bool has_flux =
_flux_bcs.count(var_name);
116 return has_fixed_value || has_flux;
121 const BoundaryName & boundary)
const 125 const bool has_flux =
_flux_bcs.count(var_name);
128 if (has_fixed_value && libmesh_map_find(
_fixed_value_bcs, var_name).count(boundary))
130 else if (has_flux && libmesh_map_find(
_flux_bcs, var_name).count(boundary))
138 const BoundaryName & boundary,
139 const std::string & requestor_name,
147 const bool has_flux =
_flux_bcs.count(var_name);
150 if (has_fixed_value && libmesh_map_find(
_fixed_value_bcs, var_name).count(boundary))
153 return libmesh_map_find(libmesh_map_find(
_fixed_value_bcs, var_name), boundary);
155 else if (has_flux && libmesh_map_find(
_flux_bcs, var_name).count(boundary))
158 return libmesh_map_find(libmesh_map_find(
_flux_bcs, var_name), boundary);
162 "Boundary condition for variable '" + var_name +
"' on boundary '" + boundary +
163 "' requested by '" + requestor_name +
164 "' has not been specified on this ActionComponent.");
167 std::vector<BoundaryName>
169 const VariableName & var_name)
const 173 const bool has_flux =
_flux_bcs.count(var_name);
175 std::vector<BoundaryName> boundaries;
178 for (
const auto & boundary_pair : libmesh_map_find(
_fixed_value_bcs, var_name))
179 boundaries.push_back(boundary_pair.first);
182 for (
const auto & boundary_pair : libmesh_map_find(
_flux_bcs, var_name))
183 boundaries.push_back(boundary_pair.first);
191 std::string list_missing =
"";
194 for (
const auto & bc_pair : var_pair.second)
197 std::make_pair(VariableName(var_pair.first), BoundaryName(bc_pair.first))) ==
199 list_missing +=
"\n- " + var_pair.first +
" on " + bc_pair.first;
202 for (
const auto & bc_pair : var_pair.second)
205 std::make_pair(VariableName(var_pair.first), BoundaryName(bc_pair.first))) ==
207 list_missing +=
"\n- " + var_pair.first +
" on " + bc_pair.first;
209 if (!list_missing.empty())
210 mooseError(
"Boundary conditions for variables and boundaries:" + list_missing +
211 "\n have been defined on this ActionComponent, but have not been requested by " static InputParameters validParams()
const std::vector< VariableName > _flux_bc_variables
Names of the variables to set a flux BC on.
MooseFunctorName getBoundaryCondition(const VariableName &variable, const BoundaryName &boundary, const std::string &requestor_name, BoundaryConditionType &bc_type) const
Get the name of the functor providing the boundary condition for the requested variable and boundary...
std::map< std::string, std::map< std::string, std::string > > _flux_bcs
Maps of the flux boundary conditions.
ComponentBoundaryConditionInterface(const InputParameters ¶ms)
const std::vector< VariableName > _fixed_value_bc_variables
Names of the variables to set a fixed value BC on.
std::set< std::pair< VariableName, BoundaryName > > _requested_bc_variables
Requested variables. If the IC for a variable was never requested, error.
Base class for components that are defined using an action.
static InputParameters validParams()
std::map< std::string, std::map< std::string, std::string > > _fixed_value_bcs
Maps of the fixed value boundary conditions.
bool hasBoundaryCondition(const VariableName &variable) const
Whether the component has a boundary condition parameter specified for the requested variable...
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void addRequiredTask(const std::string &task)
Add a new required task for all physics deriving from this class NOTE: This does not register the tas...
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::vector< BoundaryName > getBoundaryConditionBoundaries(const VariableName &variable) const
Get the name of the boundaries on which the variable should have a boundary condition.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void checkBoundaryConditionsAllRequested() const
Checks that all initial conditions were requested.
for(PetscInt i=0;i< nvars;++i)
auto index_range(const T &sizable)