LCOV - code coverage report
Current view: top level - src/components - HeatTransferBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 74 78 94.9 %
Date: 2026-05-29 20:41:18 Functions: 12 13 92.3 %
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 "HeatTransferBase.h"
      11             : #include "FlowModelSinglePhase.h"
      12             : #include "FlowChannelBase.h"
      13             : #include "ClosuresBase.h"
      14             : #include "MooseUtils.h"
      15             : 
      16             : InputParameters
      17        1034 : HeatTransferBase::validParams()
      18             : {
      19        1034 :   InputParameters params = ConnectorBase::validParams();
      20        2068 :   params.addRequiredParam<std::string>("flow_channel",
      21             :                                        "Name of flow channel component to connect to");
      22        2068 :   params.addParam<bool>(
      23        2068 :       "P_hf_transferred", false, "Is heat flux perimeter transferred from an external source?");
      24        2068 :   params.addParam<FunctionName>("P_hf", "Heat flux perimeter [m]");
      25        1034 :   return params;
      26           0 : }
      27             : 
      28         517 : HeatTransferBase::HeatTransferBase(const InputParameters & parameters)
      29             :   : ConnectorBase(parameters),
      30         517 :     _flow_channel_name(getParam<std::string>("flow_channel")),
      31        1034 :     _P_hf_transferred(getParam<bool>("P_hf_transferred")),
      32        1551 :     _P_hf_provided(isParamValid("P_hf"))
      33             : {
      34         517 :   addDependency(_flow_channel_name);
      35         517 : }
      36             : 
      37             : void
      38         474 : HeatTransferBase::init()
      39             : {
      40             :   ConnectorBase::init();
      41             : 
      42         474 :   checkComponentOfTypeExistsByName<FlowChannelBase>(_flow_channel_name);
      43             : 
      44             :   if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
      45             :   {
      46             :     const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
      47             : 
      48             :     // add the name of this heat transfer component to list for flow channel
      49         470 :     flow_channel.addHeatTransferName(name());
      50             : 
      51             :     // get various data from flow channel
      52         470 :     _flow_channel_subdomains = flow_channel.getSubdomainNames();
      53         470 :     _model_type = flow_channel.getFlowModelID();
      54             :     _fp_name = flow_channel.getFluidPropertiesName();
      55         470 :     _A_fn_name = flow_channel.getAreaFunctionName();
      56         470 :     _closures_objects = flow_channel.getClosuresObjects();
      57             :   }
      58         474 : }
      59             : 
      60             : void
      61         474 : HeatTransferBase::initSecondary()
      62             : {
      63             :   ConnectorBase::initSecondary();
      64             : 
      65             :   // determine names of heat transfer variables
      66         474 :   if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
      67             :   {
      68             :     const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
      69             : 
      70         470 :     const std::string suffix = flow_channel.getHeatTransferNamesSuffix(name());
      71             : 
      72         470 :     _P_hf_name = FlowModel::HEAT_FLUX_PERIMETER + suffix;
      73         470 :     _T_wall_name = FlowModel::TEMPERATURE_WALL + suffix;
      74         470 :     _T_wall_mat_name = FlowModel::TEMPERATURE_WALL + suffix;
      75         940 :     _q_wall_name = FlowModel::HEAT_FLUX_WALL + suffix;
      76             :   }
      77         474 : }
      78             : 
      79             : void
      80         462 : HeatTransferBase::check() const
      81             : {
      82             :   ConnectorBase::check();
      83         462 : }
      84             : 
      85             : void
      86         454 : HeatTransferBase::addVariables()
      87             : {
      88             :   // heat flux perimeter variable
      89         454 :   if (!_P_hf_transferred)
      90         454 :     addHeatedPerimeter();
      91         454 : }
      92             : 
      93             : void
      94         483 : HeatTransferBase::addMooseObjects()
      95             : {
      96             :   // create heat flux perimeter aux if not transferred from external app
      97         483 :   if (!_P_hf_transferred)
      98             :   {
      99         483 :     const std::string class_name = "FunctionAux";
     100         483 :     InputParameters params = _factory.getValidParams(class_name);
     101         966 :     params.set<AuxVariableName>("variable") = {_P_hf_name};
     102         483 :     params.set<std::vector<SubdomainName>>("block") = _flow_channel_subdomains;
     103         483 :     params.set<FunctionName>("function") = _P_hf_fn_name;
     104             : 
     105         483 :     ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum());
     106        1932 :     execute_on = {EXEC_TIMESTEP_BEGIN, EXEC_INITIAL};
     107         483 :     params.set<ExecFlagEnum>("execute_on") = execute_on;
     108             : 
     109         966 :     getTHMProblem().addAuxKernel(class_name, genName(name(), "P_hf_auxkernel"), params);
     110         483 :   }
     111         966 : }
     112             : 
     113             : void
     114         454 : HeatTransferBase::addHeatedPerimeter()
     115             : {
     116         454 :   getTHMProblem().addSimVariable(
     117         454 :       false, _P_hf_name, getTHMProblem().getFlowFEType(), _flow_channel_subdomains);
     118             : 
     119             :   // create heat flux perimeter variable if not transferred from external app
     120         454 :   if (!_P_hf_transferred)
     121             :   {
     122         454 :     if (_P_hf_provided)
     123             :     {
     124         598 :       _P_hf_fn_name = getParam<FunctionName>("P_hf");
     125             :     }
     126             :     // create heat flux perimeter function if not provided; assume circular flow channel
     127             :     else
     128             :     {
     129         310 :       _P_hf_fn_name = genName(name(), "P_hf_fn");
     130             : 
     131         155 :       const std::string class_name = "GeneralizedCircumference";
     132         155 :       InputParameters params = _factory.getValidParams(class_name);
     133         155 :       params.set<FunctionName>("area_function") = _A_fn_name;
     134         155 :       getTHMProblem().addFunction(class_name, _P_hf_fn_name, params);
     135         155 :     }
     136             : 
     137         454 :     if (!_app.isRestarting())
     138         442 :       getTHMProblem().addFunctionIC(_P_hf_name, _P_hf_fn_name, _flow_channel_subdomains);
     139             :   }
     140         454 : }
     141             : 
     142             : const VariableName &
     143         501 : HeatTransferBase::getHeatedPerimeterName() const
     144             : {
     145         501 :   checkSetupStatus(INITIALIZED_SECONDARY);
     146             : 
     147         501 :   return _P_hf_name;
     148             : }
     149             : 
     150             : const VariableName &
     151         501 : HeatTransferBase::getWallTemperatureName() const
     152             : {
     153         501 :   checkSetupStatus(INITIALIZED_SECONDARY);
     154             : 
     155         501 :   return _T_wall_name;
     156             : }
     157             : 
     158             : const MaterialPropertyName &
     159         501 : HeatTransferBase::getWallTemperatureMatName() const
     160             : {
     161         501 :   checkSetupStatus(INITIALIZED_SECONDARY);
     162             : 
     163         501 :   return _T_wall_mat_name;
     164             : }
     165             : 
     166             : const MaterialPropertyName &
     167         501 : HeatTransferBase::getWallHeatFluxName() const
     168             : {
     169         501 :   return _q_wall_name;
     170             : }
     171             : 
     172             : const UserObjectName &
     173           0 : HeatTransferBase::getFluidPropertiesName() const
     174             : {
     175           0 :   checkSetupStatus(INITIALIZED_PRIMARY);
     176             : 
     177           0 :   return _fp_name;
     178             : }

Generated by: LCOV version 1.14