LCOV - code coverage report
Current view: top level - src/components - HeatSourceBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 26 28 92.9 %
Date: 2026-05-29 20:41:18 Functions: 3 3 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 "HeatSourceBase.h"
      11             : #include "HeatStructureBase.h"
      12             : #include "HeatStructureInterface.h"
      13             : #include "HeatStructureFromFile3D.h"
      14             : 
      15             : InputParameters
      16         224 : HeatSourceBase::validParams()
      17             : {
      18         224 :   InputParameters params = Component::validParams();
      19         448 :   params.addRequiredParam<std::string>("hs", "Heat structure in which to apply heat source");
      20         448 :   params.addRequiredParam<std::vector<std::string>>(
      21             :       "regions", "Heat structure regions where heat generation is to be applied");
      22         224 :   params.addClassDescription("Base class for heat source components");
      23         224 :   return params;
      24           0 : }
      25             : 
      26         112 : HeatSourceBase::HeatSourceBase(const InputParameters & parameters)
      27             :   : Component(parameters),
      28         112 :     _hs_name(getParam<std::string>("hs")),
      29         336 :     _region_names(getParam<std::vector<std::string>>("regions"))
      30             : {
      31         112 :   checkSizeGreaterThan<std::string>("regions", 0);
      32             : 
      33         236 :   for (auto && region : _region_names)
      34         248 :     _subdomain_names.push_back(genName(_hs_name, region));
      35         112 : }
      36             : 
      37             : void
      38         112 : HeatSourceBase::check() const
      39             : {
      40             :   Component::check();
      41             : 
      42         112 :   checkComponentOfTypeExists<HeatStructureInterface>("hs");
      43             : 
      44         224 :   if (hasComponent<HeatStructureBase>("hs"))
      45             :   {
      46          96 :     const HeatStructureBase & hs = getComponent<HeatStructureBase>("hs");
      47         204 :     for (auto && region : _region_names)
      48         108 :       if (!hs.hasBlock(region))
      49          12 :         logError("Region '",
      50             :                  region,
      51             :                  "' does not exist in heat structure '",
      52             :                  getParam<std::string>("hs"),
      53             :                  "'.");
      54             :   }
      55          32 :   else if (hasComponent<HeatStructureFromFile3D>("hs"))
      56             :   {
      57          12 :     const HeatStructureFromFile3D & hs = getComponent<HeatStructureFromFile3D>("hs");
      58          24 :     for (auto && region : _region_names)
      59          12 :       if (!hs.hasRegion(region))
      60           0 :         logError("Region '",
      61             :                  region,
      62             :                  "' does not exist in heat structure '",
      63             :                  getParam<std::string>("hs"),
      64             :                  "'.");
      65             :   }
      66             :   else
      67           4 :     logError("Heat structure must be of type 'HeatStructureBase' or 'HeatStructureFromFile3D'.");
      68         112 : }

Generated by: LCOV version 1.14