https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HSBoundaryInterface.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
10#include "HSBoundaryInterface.h"
11#include "Component.h"
12#include "THMMesh.h"
13
16{
18
19 params.addRequiredParam<std::string>("hs", "Heat structure name");
20 params.addParam<MooseEnum>(
21 "hs_side", Component2D::getExternalBoundaryTypeMooseEnum(), "Heat structure side");
22 params.addParam<BoundaryName>("hs_boundary", "Name of the coupled heat structure boundary.");
23
24 return params;
25}
26
28 : _hs_name(component->getParam<std::string>("hs")),
29 _hs_side(component->getEnumParam<Component2D::ExternalBoundaryType>("hs_side", false)),
30 _hs_side_valid(static_cast<int>(_hs_side) >= 0)
31{
32 component->addDependency(_hs_name);
33
34 component->checkMutuallyExclusiveParameters({"hs_side", "hs_boundary"});
35}
36
37void
38HSBoundaryInterface::check(const Component * const component) const
39{
40 component->checkComponentOfTypeExistsByName<HeatStructureBase>(_hs_name);
41
42 if (component->hasComponentByName<HeatStructureBase>(_hs_name))
43 {
44 const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name);
45
46 BoundaryName hs_boundary;
48 if (component->isParamValid("hs_side"))
49 {
51 {
52 hs_boundary = hs.getExternalBoundaryName(_hs_side);
53 hs_side = _hs_side;
54 }
55 else
56 {
57 component->logError("The parameter 'hs_side' was given an invalid value.");
58 return;
59 }
60 }
61 else
62 {
63 hs_boundary = component->getParam<BoundaryName>("hs_boundary");
64 hs_side = hs.getExternalBoundaryType(hs_boundary);
65 }
66
67 if (!hs.hasBoundary(hs_boundary))
68 component->logError("The heat structure boundary '", hs_boundary, "' does not exist.");
69
70 const Real & P_hs = hs.getUnitPerimeter(hs_side);
71 if (MooseUtils::absoluteFuzzyEqual(P_hs, 0.))
72 {
73 if (component->isParamValid("hs_side"))
74 component->logError("'hs_side' parameter is set to '",
75 component->getParam<MooseEnum>("hs_side"),
76 "', but this side of the heat structure '",
78 "' has radius of zero.");
79 else
80 component->logError("The specified boundary '",
81 hs_boundary,
82 "' of the heat structure '",
84 "' has a radius of zero.");
85 }
86 if (std::isnan(P_hs))
87 component->logError("The specified boundary '",
88 hs_boundary,
89 "' of the heat structure '",
91 "' is either START and END boundary, which may not be used.");
92 }
93}
94
95const BoundaryName &
97{
98 if (component->isParamValid("hs_side"))
99 {
100 const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name);
102 }
103 else
104 return component->getParam<BoundaryName>("hs_boundary");
105}
106
109{
110 if (component->isParamValid("hs_side"))
111 return _hs_side;
112 else
113 {
114 const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name);
115 const auto hs_boundary = component->getParam<BoundaryName>("hs_boundary");
116 return hs.getExternalBoundaryType(hs_boundary);
117 }
118}
119
120bool
122{
123 const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name);
124
125 BoundaryName hs_boundary;
126 if (component->isParamValid("hs_side"))
127 {
128 if (_hs_side_valid)
129 hs_boundary = hs.getExternalBoundaryName(_hs_side);
130 else
131 return false;
132 }
133 else
134 hs_boundary = component->getParam<BoundaryName>("hs_boundary");
135
136 return hs.hasBoundary(hs_boundary);
137}
InputParameters emptyInputParameters()
void ErrorVector unsigned int
ExternalBoundaryType
External boundary type.
Definition Component2D.h:19
static MooseEnum getExternalBoundaryTypeMooseEnum(const std::string &default_value="")
Gets the MooseEnum corresponding to ExternalBoundaryType.
Definition Component2D.C:21
const BoundaryName & getExternalBoundaryName(const ExternalBoundaryType &boundary_type) const
Gets the name of an external boundary by type.
Base class for THM components.
Definition Component.h:32
const std::string & _hs_name
Heat structure name.
const BoundaryName & getHSBoundaryName(const Component *const component) const
Gets the boundary name corresponding to the heat structure and side.
Component2D::ExternalBoundaryType _hs_side
Heat structure side.
static InputParameters validParams()
bool HSBoundaryIsValid(const Component *const component) const
Returns true if the specified heat structure boundary is valid.
bool _hs_side_valid
True if the heat structure side enum is valid.
HSBoundaryInterface(Component *component)
Component2D::ExternalBoundaryType getHSExternalBoundaryType(const Component *const component) const
Gets the external boundary type for the coupled heat structure boundary.
void check(const Component *const component) const
Base class for 2D generated heat structures.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)