https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeatStructure2DCouplerBase.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
11#include "HeatStructurePlate.h"
13#include "THMMesh.h"
14
17{
19
20 params.addRequiredParam<std::string>("primary_heat_structure",
21 "The first heat structure to couple");
22 params.addRequiredParam<std::string>("secondary_heat_structure",
23 "The second heat structure to couple");
24 params.addRequiredParam<BoundaryName>("primary_boundary",
25 "The boundary of the first heat structure to couple");
26 params.addRequiredParam<BoundaryName>("secondary_boundary",
27 "The boundary of the second heat structure to couple");
28
29 return params;
30}
31
33 : BoundaryBase(parameters),
34
35 _hs_names({getParam<std::string>("primary_heat_structure"),
36 getParam<std::string>("secondary_heat_structure")}),
37 _hs_boundaries(
38 {getParam<BoundaryName>("primary_boundary"), getParam<BoundaryName>("secondary_boundary")}),
39
40 _mesh_alignment(constMesh()),
41 _is_plate({false, false}),
42 _is_cylindrical({false, false})
43{
44 addDependency(_hs_names[0]);
45 addDependency(_hs_names[1]);
46}
47
48void
50{
52
53 if (hasComponentByName<HeatStructureBase>(_hs_names[0]) &&
54 hasComponentByName<HeatStructureBase>(_hs_names[1]))
55 {
56 const HeatStructureBase & primary_hs = getComponentByName<HeatStructureBase>(_hs_names[0]);
57 const HeatStructureBase & secondary_hs = getComponentByName<HeatStructureBase>(_hs_names[1]);
58
59 if (primary_hs.hasBoundary(_hs_boundaries[0]) && secondary_hs.hasBoundary(_hs_boundaries[1]))
60 {
61 // Initialize the alignment mapping
63 secondary_hs.getBoundaryInfo(_hs_boundaries[1]));
64
65 // Add entries to sparsity pattern for coupling
67 for (const auto & elem_id : _mesh_alignment.getPrimaryElemIDs())
68 {
71 }
72 }
73 }
74}
75
76void
78{
80
81 if (hasComponentByName<HeatStructureBase>(_hs_names[0]) &&
82 hasComponentByName<HeatStructureBase>(_hs_names[1]))
83 {
84 const HeatStructureBase & primary_hs = getComponentByName<HeatStructureBase>(_hs_names[0]);
85 const HeatStructureBase & secondary_hs = getComponentByName<HeatStructureBase>(_hs_names[1]);
86
87 if (primary_hs.hasBoundary(_hs_boundaries[0]) && secondary_hs.hasBoundary(_hs_boundaries[1]))
88 {
89 // Get the heat structure types
90 _hs_side_types.resize(2);
93
94 // Areas
95 _areas.resize(2);
96 _areas[0] = primary_hs.getBoundaryArea(_hs_boundaries[0]);
97 _areas[1] = secondary_hs.getBoundaryArea(_hs_boundaries[1]);
98
99 // Compute the coupling area fractions in case areas are not equal
100 _coupling_area_fractions.resize(2);
101 if (_areas[0] > _areas[1])
102 {
105 }
106 else
107 {
110 }
111 }
112 }
113
114 for (unsigned int i = 0; i < 2; i++)
115 {
116 if (hasComponentByName<HeatStructurePlate>(_hs_names[i]))
117 _is_plate[i] = true;
118 if (hasComponentByName<HeatStructureCylindricalBase>(_hs_names[i]))
119 _is_cylindrical[i] = true;
120 }
121}
122
123void
125{
127
128 for (unsigned int i = 0; i < 2; i++)
129 {
130 checkComponentOfTypeExistsByName<HeatStructureBase>(_hs_names[i]);
131
132 if (hasComponentByName<HeatStructureBase>(_hs_names[i]))
133 {
134 const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_names[i]);
135 if (!hs.hasBoundary(_hs_boundaries[i]))
136 logError("The heat structure '",
137 _hs_names[i],
138 "' does not have the boundary '",
140 "'.");
141
142 if ((!_is_plate[i]) && (!_is_cylindrical[i]))
143 logError("The type of the heat structure '",
144 _hs_names[i],
145 "' is not 'HeatStructurePlate' or inherited from 'HeatStructureCylindricalBase'.");
146 }
147 }
148
149 if ((_is_plate[0] && _is_cylindrical[1]) || (_is_cylindrical[0] && _is_plate[1]))
150 logError("The coupled heat structures must have the same type.");
151}
Base class for components of a boundary type.
static InputParameters validParams()
bool hasBoundary(const BoundaryName &boundary_name) const
Returns true if this component has the supplied boundary.
const Real & getBoundaryArea(const BoundaryName &boundary_name) const
Gets the area for a boundary.
ExternalBoundaryType getExternalBoundaryType(const BoundaryName &boundary_name) const
Gets the external boundary type of the given boundary.
const std::vector< std::tuple< dof_id_type, unsigned short int > > & getBoundaryInfo(const BoundaryName &boundary_name) const
Gets boundary info associated with the component boundary.
virtual void init()
Initializes the component.
Definition Component.h:405
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
virtual void check() const
Check the component integrity.
Definition Component.h:416
virtual void setupMesh()
Performs mesh setup such as creating mesh or naming mesh sets.
Definition Component.h:421
std::vector< Component2D::ExternalBoundaryType > _hs_side_types
Heat structure side types for each boundary.
virtual void check() const override
Check the component integrity.
MeshAlignment _mesh_alignment
Mesh alignment.
std::vector< bool > _is_plate
Flag for each heat structure being HeatStructurePlate.
const std::vector< std::string > _hs_names
Primary and secondary heat structure names.
static InputParameters validParams()
HeatStructure2DCouplerBase(const InputParameters &parameters)
std::vector< bool > _is_cylindrical
Flag for each heat structure deriving from HeatStructureCylindricalBase.
const std::vector< BoundaryName > _hs_boundaries
Primary and secondary heat structure boundaries.
virtual void init() override
Initializes the component.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
std::vector< Real > _coupling_area_fractions
Area fractions by which to multiply coupling terms.
std::vector< Real > _areas
Areas for the primary and secondary sides.
Base class for 2D generated heat structures.
void addRequiredParam(const std::string &name, const std::string &doc_string)
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.
void initialize(const std::vector< dof_id_type > &primary_elem_ids, const std::vector< std::tuple< dof_id_type, unsigned short int > > &secondary_boundary_info)
Extracts mesh information and builds the mapping.
bool hasCoupledElemID(const dof_id_type &elem_id) const
Returns true if the element ID has a coupled element ID.
const dof_id_type & getCoupledElemID(const dof_id_type &elem_id) const
Gets the coupled element ID for a given element ID.
virtual void augmentSparsity(const dof_id_type &elem_id1, const dof_id_type &elem_id2)
Hint how to augment sparsity pattern between two elements.
Definition Simulation.C:71