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 "HSBoundary.h" 11 : #include "HeatStructureBase.h" 12 : #include "MooseUtils.h" 13 : 14 : InputParameters 15 1228 : HSBoundary::validParams() 16 : { 17 1228 : InputParameters params = BoundaryBase::validParams(); 18 : 19 2456 : params.addRequiredParam<std::vector<BoundaryName>>( 20 : "boundary", "List of boundary names for which this component applies"); 21 2456 : params.addRequiredParam<std::string>("hs", "Heat structure name"); 22 : 23 1228 : return params; 24 0 : } 25 : 26 612 : HSBoundary::HSBoundary(const InputParameters & params) 27 : : BoundaryBase(params), 28 : 29 612 : _boundary(getParam<std::vector<BoundaryName>>("boundary")), 30 1836 : _hs_name(getParam<std::string>("hs")) 31 : { 32 612 : } 33 : 34 : void 35 612 : HSBoundary::check() const 36 : { 37 612 : checkComponentOfTypeExistsByName<HeatStructureInterface>(_hs_name); 38 : 39 612 : if (hasComponentByName<HeatStructureBase>(_hs_name)) 40 : { 41 : const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name); 42 : 43 : // Check that no perimeter is zero; if so, there is not physically a boundary 44 1070 : for (unsigned int i = 0; i < _boundary.size(); i++) 45 : { 46 546 : if (hs.hasExternalBoundary(_boundary[i])) 47 : { 48 534 : auto hs_side = hs.getExternalBoundaryType(_boundary[i]); 49 534 : if ((hs_side == Component2D::ExternalBoundaryType::INNER) || 50 : (hs_side == Component2D::ExternalBoundaryType::OUTER)) 51 : { 52 406 : if (MooseUtils::absoluteFuzzyEqual(hs.getUnitPerimeter(hs_side), 0)) 53 2 : logError("The heat structure side of the heat structure '", 54 2 : _hs_name, 55 : "' corresponding to the boundary name '", 56 2 : _boundary[i], 57 : "' has a zero perimeter. This can be caused by applying the boundary on the " 58 : "axis of symmetry of a cylindrical heat structure."); 59 : } 60 : } 61 : } 62 : } 63 612 : } 64 : 65 : bool 66 18 : HSBoundary::allComponent2DBoundariesAreExternal() const 67 : { 68 18 : const auto & comp2d = getComponentByName<Component2D>(_hs_name); 69 36 : for (const auto & boundary : _boundary) 70 18 : if (!comp2d.hasExternalBoundary(boundary)) 71 : return false; 72 : return true; 73 : } 74 : 75 : void 76 9 : HSBoundary::checkAllComponent2DBoundariesAreExternal() const 77 : { 78 9 : if (!allComponent2DBoundariesAreExternal()) 79 0 : logError("The boundaries given in 'boundary' must all be external."); 80 9 : } 81 : 82 : bool 83 18 : HSBoundary::hasCommonComponent2DExternalBoundaryType() const 84 : { 85 18 : if (!_boundary.empty()) 86 : { 87 18 : const auto & comp2d = getComponentByName<Component2D>(_hs_name); 88 18 : const auto common_boundary_type = comp2d.getExternalBoundaryType(_boundary[0]); 89 18 : for (unsigned int i = 1; i < _boundary.size(); i++) 90 : { 91 0 : const auto boundary_type = comp2d.getExternalBoundaryType(_boundary[i]); 92 0 : if (boundary_type != common_boundary_type) 93 : return false; 94 : } 95 : return true; 96 : } 97 0 : mooseError("No boundaries were supplied in 'boundary'."); 98 : } 99 : 100 : Component2D::ExternalBoundaryType 101 9 : HSBoundary::getCommonComponent2DExternalBoundaryType() const 102 : { 103 9 : if (hasCommonComponent2DExternalBoundaryType()) 104 : { 105 9 : const auto & comp2d = getComponentByName<Component2D>(_hs_name); 106 9 : return comp2d.getExternalBoundaryType(_boundary[0]); 107 : } 108 : else 109 0 : mooseError( 110 : "The boundaries supplied in 'boundary' do not have a common external boundary type."); 111 : }