LCOV - code coverage report
Current view: top level - src/components - HSBoundaryExternalAppConvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 34 50 68.0 %
Date: 2026-05-29 20:41:18 Functions: 4 4 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 "HSBoundaryExternalAppConvection.h"
      11             : #include "HeatStructureCylindricalBase.h"
      12             : #include "HeatConductionModel.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", HSBoundaryExternalAppConvection);
      15             : 
      16             : InputParameters
      17          16 : HSBoundaryExternalAppConvection::validParams()
      18             : {
      19          16 :   InputParameters params = HSBoundary::validParams();
      20             : 
      21          32 :   params.addParam<VariableName>("T_ext", "T_ext", "Temperature from external application");
      22          32 :   params.addParam<VariableName>(
      23             :       "htc_ext", "htc_ext", "Heat transfer coefficient from external application");
      24          32 :   params.addParam<FunctionName>("scale", 1.0, "Function by which to scale the boundary condition");
      25          32 :   params.addParam<bool>(
      26             :       "scale_heat_rate_pp",
      27          32 :       true,
      28             :       "If true, the scaling function is applied to the heat rate post-processor.");
      29             : 
      30          16 :   params.addClassDescription("Heat structure boundary condition to perform convective heat "
      31             :                              "transfer with an external application");
      32          16 :   return params;
      33           0 : }
      34             : 
      35           8 : HSBoundaryExternalAppConvection::HSBoundaryExternalAppConvection(const InputParameters & params)
      36             :   : HSBoundary(params),
      37             : 
      38           8 :     _T_ext_var_name(getParam<VariableName>("T_ext")),
      39          24 :     _htc_ext_var_name(getParam<VariableName>("htc_ext"))
      40             : {
      41           8 : }
      42             : 
      43             : void
      44           8 : HSBoundaryExternalAppConvection::addVariables()
      45             : {
      46          16 :   const HeatStructureInterface & hs = getComponent<HeatStructureInterface>("hs");
      47             :   const std::vector<SubdomainName> & subdomain_names =
      48           8 :       hs.getGeometricalComponent().getSubdomainNames();
      49             : 
      50           8 :   getTHMProblem().addSimVariable(
      51             :       false, _T_ext_var_name, HeatConductionModel::feType(), subdomain_names);
      52           8 :   getTHMProblem().addSimVariable(
      53             :       false, _htc_ext_var_name, HeatConductionModel::feType(), subdomain_names);
      54           8 : }
      55             : 
      56             : void
      57           8 : HSBoundaryExternalAppConvection::addMooseObjects()
      58             : {
      59           8 :   const HeatStructureInterface & hs = getComponent<HeatStructureInterface>("hs");
      60             :   const HeatStructureCylindricalBase * hs_cyl =
      61           8 :       dynamic_cast<const HeatStructureCylindricalBase *>(&hs);
      62             :   const bool is_cylindrical = hs_cyl != nullptr;
      63             : 
      64             :   {
      65             :     const std::string class_name = is_cylindrical ? "ADExternalAppConvectionHeatTransferRZBC"
      66          16 :                                                   : "ADExternalAppConvectionHeatTransferBC";
      67           8 :     InputParameters pars = _factory.getValidParams(class_name);
      68          16 :     pars.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
      69           8 :     pars.set<std::vector<BoundaryName>>("boundary") = _boundary;
      70          24 :     pars.set<std::vector<VariableName>>("T_ext") = {_T_ext_var_name};
      71          24 :     pars.set<std::vector<VariableName>>("htc_ext") = {_htc_ext_var_name};
      72           8 :     if (is_cylindrical)
      73             :     {
      74           0 :       pars.set<Point>("axis_point") = hs_cyl->getPosition();
      75           0 :       pars.set<RealVectorValue>("axis_dir") = hs_cyl->getDirection();
      76             :     }
      77          24 :     pars.set<FunctionName>("scale") = getParam<FunctionName>("scale");
      78             : 
      79          16 :     getTHMProblem().addBoundaryCondition(class_name, genName(name(), "bc"), pars);
      80           8 :   }
      81             : 
      82             :   // Create integral PP for cylindrical heat structures
      83           8 :   if (is_cylindrical)
      84             :   {
      85           0 :     const std::string class_name = "HeatRateExternalAppConvectionRZ";
      86           0 :     InputParameters pars = _factory.getValidParams(class_name);
      87           0 :     pars.set<std::vector<BoundaryName>>("boundary") = _boundary;
      88           0 :     pars.set<std::vector<VariableName>>("T") = {HeatConductionModel::TEMPERATURE};
      89           0 :     pars.set<std::vector<VariableName>>("T_ext") = {_T_ext_var_name};
      90           0 :     pars.set<std::vector<VariableName>>("htc_ext") = {_htc_ext_var_name};
      91           0 :     pars.set<Point>("axis_point") = hs_cyl->getPosition();
      92           0 :     pars.set<RealVectorValue>("axis_dir") = hs_cyl->getDirection();
      93           0 :     if (getParam<bool>("scale_heat_rate_pp"))
      94           0 :       pars.set<FunctionName>("scale") = getParam<FunctionName>("scale");
      95           0 :     pars.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
      96           0 :     getTHMProblem().addPostprocessor(class_name, genSafeName(name(), "integral"), pars);
      97           0 :   }
      98          24 : }

Generated by: LCOV version 1.14