Line data Source code
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 : 14 : InputParameters 15 604 : HSBoundaryInterface::validParams() 16 : { 17 604 : InputParameters params = emptyInputParameters(); 18 : 19 1208 : params.addRequiredParam<std::string>("hs", "Heat structure name"); 20 1208 : params.addParam<MooseEnum>( 21 1812 : "hs_side", Component2D::getExternalBoundaryTypeMooseEnum(), "Heat structure side"); 22 1208 : params.addParam<BoundaryName>("hs_boundary", "Name of the coupled heat structure boundary."); 23 : 24 604 : return params; 25 0 : } 26 : 27 302 : HSBoundaryInterface::HSBoundaryInterface(Component * component) 28 604 : : _hs_name(component->getParam<std::string>("hs")), 29 302 : _hs_side(component->getEnumParam<Component2D::ExternalBoundaryType>("hs_side", false)), 30 302 : _hs_side_valid(static_cast<int>(_hs_side) >= 0) 31 : { 32 302 : component->addDependency(_hs_name); 33 : 34 906 : component->checkMutuallyExclusiveParameters({"hs_side", "hs_boundary"}); 35 604 : } 36 : 37 : void 38 282 : HSBoundaryInterface::check(const Component * const component) const 39 : { 40 282 : component->checkComponentOfTypeExistsByName<HeatStructureBase>(_hs_name); 41 : 42 282 : if (component->hasComponentByName<HeatStructureBase>(_hs_name)) 43 : { 44 : const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name); 45 : 46 : BoundaryName hs_boundary; 47 : Component2D::ExternalBoundaryType hs_side; 48 560 : if (component->isParamValid("hs_side")) 49 : { 50 261 : if (_hs_side_valid) 51 : { 52 259 : hs_boundary = hs.getExternalBoundaryName(_hs_side); 53 259 : hs_side = _hs_side; 54 : } 55 : else 56 : { 57 2 : component->logError("The parameter 'hs_side' was given an invalid value."); 58 : return; 59 : } 60 : } 61 : else 62 : { 63 19 : hs_boundary = component->getParam<BoundaryName>("hs_boundary"); 64 19 : hs_side = hs.getExternalBoundaryType(hs_boundary); 65 : } 66 : 67 278 : if (!hs.hasBoundary(hs_boundary)) 68 0 : component->logError("The heat structure boundary '", hs_boundary, "' does not exist."); 69 : 70 278 : const Real & P_hs = hs.getUnitPerimeter(hs_side); 71 278 : if (MooseUtils::absoluteFuzzyEqual(P_hs, 0.)) 72 : { 73 4 : if (component->isParamValid("hs_side")) 74 4 : component->logError("'hs_side' parameter is set to '", 75 : component->getParam<MooseEnum>("hs_side"), 76 : "', but this side of the heat structure '", 77 2 : _hs_name, 78 : "' has radius of zero."); 79 : else 80 0 : component->logError("The specified boundary '", 81 : hs_boundary, 82 : "' of the heat structure '", 83 0 : _hs_name, 84 : "' has a radius of zero."); 85 : } 86 278 : if (std::isnan(P_hs)) 87 2 : component->logError("The specified boundary '", 88 : hs_boundary, 89 : "' of the heat structure '", 90 2 : _hs_name, 91 : "' is either START and END boundary, which may not be used."); 92 : } 93 : } 94 : 95 : const BoundaryName & 96 872 : HSBoundaryInterface::getHSBoundaryName(const Component * const component) const 97 : { 98 1744 : if (component->isParamValid("hs_side")) 99 : { 100 815 : const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name); 101 815 : return hs.getExternalBoundaryName(_hs_side); 102 : } 103 : else 104 114 : return component->getParam<BoundaryName>("hs_boundary"); 105 : } 106 : 107 : Component2D::ExternalBoundaryType 108 288 : HSBoundaryInterface::getHSExternalBoundaryType(const Component * const component) const 109 : { 110 576 : if (component->isParamValid("hs_side")) 111 269 : return _hs_side; 112 : else 113 : { 114 19 : const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name); 115 19 : const auto hs_boundary = component->getParam<BoundaryName>("hs_boundary"); 116 19 : return hs.getExternalBoundaryType(hs_boundary); 117 : } 118 : } 119 : 120 : bool 121 298 : HSBoundaryInterface::HSBoundaryIsValid(const Component * const component) const 122 : { 123 298 : const auto & hs = component->getComponentByName<HeatStructureBase>(_hs_name); 124 : 125 : BoundaryName hs_boundary; 126 596 : if (component->isParamValid("hs_side")) 127 : { 128 279 : if (_hs_side_valid) 129 277 : hs_boundary = hs.getExternalBoundaryName(_hs_side); 130 : else 131 : return false; 132 : } 133 : else 134 38 : hs_boundary = component->getParam<BoundaryName>("hs_boundary"); 135 : 136 296 : return hs.hasBoundary(hs_boundary); 137 : }