23 "The heat structures to couple");
25 "boundaries",
"The boundaries of the heat structures to couple");
28 "emissivities > 0 & emissivities < 1",
29 "Emissivities of each heat structure surface");
32 "view_factors >= 0 & view_factors <= 1",
33 "The view factors between each surface, as a matrix. The row/column ordering corresponds to "
34 "the ordering in 'heat_structures', with an additional row and column if "
35 "'include_environment' is set to 'true'. Each row must sum to one.");
37 "include_environment",
38 "Whether or not to include an environment surrounding all of the surfaces. If the heat "
39 "structure surfaces themselves form an enclosure, then set this parameter to 'false'.");
42 "Environment temperature [K]. Only set if 'include_environment' is set to true.");
44 params.
addClassDescription(
"Couples boundaries of multiple 2D heat structures via radiation");
52 _hs_names(getParam<
std::vector<
std::string>>(
"heat_structures")),
53 _hs_boundaries(getParam<
std::vector<BoundaryName>>(
"boundaries")),
54 _include_environment(getParam<bool>(
"include_environment")),
55 _n_hs(_hs_names.size()),
56 _n_surfaces(_include_environment ? _n_hs + 1 : _n_hs),
58 _mesh_alignment(constMesh())
60 for (
unsigned int i = 0; i <
_n_hs; ++i)
74 std::vector<std::vector<std::tuple<dof_id_type, unsigned short int>>> boundary_infos;
75 for (
const auto i : index_range(
_hs_names))
77 if (hasComponentByName<HeatStructureBase>(
_hs_names[i]))
79 const auto & hs = getComponentByName<HeatStructureBase>(
_hs_names[i]);
86 if (hasComponentByName<HeatStructureBase>(
_hs_names[0]))
88 const auto & hs = getComponentByName<HeatStructureBase>(
_hs_names[0]);
97 std::vector<dof_id_type> elem_ids;
98 elem_ids.push_back(primary_elem_id);
99 elem_ids.insert(elem_ids.end(), coupled_elem_ids.begin(), coupled_elem_ids.end());
101 for (
unsigned int i = 0; i < elem_ids.size(); ++i)
102 for (
unsigned int j = i + 1; j < elem_ids.size(); ++j)
113 checkEqualSize<BoundaryName, std::string>(
"boundaries",
"heat_structures");
114 checkEqualSize<Real, std::string>(
"emissivities",
"heat_structures");
117 const auto & view_factors = getParam<std::vector<std::vector<Real>>>(
"view_factors");
118 bool correct_size =
true;
121 for (
const auto i : index_range(view_factors))
123 correct_size =
false;
126 correct_size =
false;
128 logError(
"The parameter 'view_factors' must be a square matrix of size ",
130 ". For example, a size 2 matrix is provided as '0.2 0.8; 0.7 0.3'. The row/column "
131 "ordering corresponds to the ordering in 'heat_structures', with an additional "
132 "row/column if 'include_environment' is set to 'true'.");
135 bool all_row_sums_unity =
true;
136 for (
const auto i : index_range(view_factors))
137 if (!MooseUtils::absoluteFuzzyEqual(
138 std::accumulate(view_factors[i].begin(), view_factors[i].end(), 0.0), 1.0))
139 all_row_sums_unity =
false;
140 if (!all_row_sums_unity)
141 logError(
"All rows in 'view_factors' must sum to one.");
144 logError(
"The meshes of the heat structures are not aligned.");
146 for (
const auto i : index_range(
_hs_names))
149 checkComponentOfTypeExistsByName<HeatStructureCylindricalBase>(
_hs_names[i]);
151 if (hasComponentByName<HeatStructureBase>(
_hs_names[i]))
153 const auto & hs = getComponentByName<HeatStructureBase>(
_hs_names[i]);
157 "' does not have the boundary '",
168 const UserObjectName temperature_uo_name =
genName(
name(),
"temperature_uo");
170 const std::string class_name =
"StoreVariableByElemIDSideUserObject";
176 params.
set<
int>(
"execution_order_group") = -1;
181 const UserObjectName hs_coupler_2d2d_uo_name =
genName(
name(),
"uo");
183 const std::string class_name =
"HSCoupler2D2DRadiationUserObject";
187 parameters(), {
"emissivities",
"view_factors",
"include_environment",
"T_environment"});
188 params.
set<UserObjectName>(
"temperature_uo") = temperature_uo_name;
195 for (
unsigned int i = 0; i <
_n_hs; ++i)
197 const auto & hs = getComponentByName<HeatStructureCylindricalBase>(
_hs_names[i]);
199 const std::string class_name =
"HSCoupler2D2DRadiationRZBC";
203 params.
set<UserObjectName>(
"hs_coupler_2d2d_uo") = hs_coupler_2d2d_uo_name;
204 params.
set<Point>(
"axis_point") = hs.getPosition();
205 params.
set<RealVectorValue>(
"axis_dir") = hs.getDirection();
registerMooseObject("ThermalHydraulicsApp", HSCoupler2D2DRadiation)
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
Base class for components of a boundary type.
static InputParameters validParams()
void logError(Args &&... args) const
Logs an error.
void addDependency(const std::string &dependency)
Adds a component name to the list of dependencies.
THMProblem & getTHMProblem() const
Gets the THM problem.
Factory & _factory
The Factory associated with the MooseApp.
virtual void check() const
Check the component integrity.
virtual void setupMesh()
Performs mesh setup such as creating mesh or naming mesh sets.
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters ¶meters)
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters ¶meters)
InputParameters getValidParams(const std::string &name) const
Couples boundaries of multiple 2D heat structures via radiation.
const std::vector< std::string > _hs_names
Heat structure names.
MeshAlignment2D2D _mesh_alignment
Mesh alignment object.
virtual void check() const override
Check the component integrity.
const std::vector< BoundaryName > _hs_boundaries
Heat structure boundary names.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
const unsigned int _n_hs
Number of heat structures.
const unsigned int _n_surfaces
Number of surfaces.
virtual void addMooseObjects() override
static InputParameters validParams()
HSCoupler2D2DRadiation(const InputParameters ¶meters)
static const std::string TEMPERATURE
Builds mapping between multiple 2D boundaries.
void initialize(const std::vector< std::vector< std::tuple< dof_id_type, unsigned short int > > > &boundary_infos, const Point &axis_point, const RealVectorValue &axis_direction)
Extracts mesh information and builds the mapping.
const std::vector< dof_id_type > & getPrimaryElemIDs() const
Returns the list of element IDs on the primary boundary.
bool meshesAreAligned() const
Returns true if the primary and secondary meshes are aligned.
const std::vector< dof_id_type > & getCoupledSecondaryElemIDs(const dof_id_type &primary_elem_id) const
Gets the coupled secondary element IDs for a given primary element ID.
const InputParameters & parameters() const
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.
virtual void augmentSparsity(const dof_id_type &elem_id1, const dof_id_type &elem_id2)
Hint how to augment sparsity pattern between two elements.