LCOV - code coverage report
Current view: top level - src/components - HSBoundary.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 37 43 86.0 %
Date: 2026-05-29 20:41:18 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          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         648 : HSBoundary::validParams()
      16             : {
      17         648 :   InputParameters params = BoundaryBase::validParams();
      18             : 
      19        1296 :   params.addRequiredParam<std::vector<BoundaryName>>(
      20             :       "boundary", "List of boundary names for which this component applies");
      21        1296 :   params.addRequiredParam<std::string>("hs", "Heat structure name");
      22             : 
      23         648 :   return params;
      24           0 : }
      25             : 
      26         322 : HSBoundary::HSBoundary(const InputParameters & params)
      27             :   : BoundaryBase(params),
      28             : 
      29         322 :     _boundary(getParam<std::vector<BoundaryName>>("boundary")),
      30         966 :     _hs_name(getParam<std::string>("hs"))
      31             : {
      32         322 : }
      33             : 
      34             : void
      35         322 : HSBoundary::check() const
      36             : {
      37         322 :   checkComponentOfTypeExistsByName<HeatStructureInterface>(_hs_name);
      38             : 
      39         322 :   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         540 :     for (unsigned int i = 0; i < _boundary.size(); i++)
      45             :     {
      46         276 :       if (hs.hasExternalBoundary(_boundary[i]))
      47             :       {
      48         264 :         auto hs_side = hs.getExternalBoundaryType(_boundary[i]);
      49         264 :         if ((hs_side == Component2D::ExternalBoundaryType::INNER) ||
      50             :             (hs_side == Component2D::ExternalBoundaryType::OUTER))
      51             :         {
      52         212 :           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         322 : }
      64             : 
      65             : bool
      66          16 : HSBoundary::allComponent2DBoundariesAreExternal() const
      67             : {
      68          16 :   const auto & comp2d = getComponentByName<Component2D>(_hs_name);
      69          32 :   for (const auto & boundary : _boundary)
      70          16 :     if (!comp2d.hasExternalBoundary(boundary))
      71             :       return false;
      72             :   return true;
      73             : }
      74             : 
      75             : void
      76           8 : HSBoundary::checkAllComponent2DBoundariesAreExternal() const
      77             : {
      78           8 :   if (!allComponent2DBoundariesAreExternal())
      79           0 :     logError("The boundaries given in 'boundary' must all be external.");
      80           8 : }
      81             : 
      82             : bool
      83          16 : HSBoundary::hasCommonComponent2DExternalBoundaryType() const
      84             : {
      85          16 :   if (!_boundary.empty())
      86             :   {
      87          16 :     const auto & comp2d = getComponentByName<Component2D>(_hs_name);
      88          16 :     const auto common_boundary_type = comp2d.getExternalBoundaryType(_boundary[0]);
      89          16 :     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           8 : HSBoundary::getCommonComponent2DExternalBoundaryType() const
     102             : {
     103           8 :   if (hasCommonComponent2DExternalBoundaryType())
     104             :   {
     105           8 :     const auto & comp2d = getComponentByName<Component2D>(_hs_name);
     106           8 :     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             : }

Generated by: LCOV version 1.14