LCOV - code coverage report
Current view: top level - src/materials - SideSetHeatTransferMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 68 77 88.3 %
Date: 2025-09-04 07:53:51 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 "SideSetHeatTransferMaterial.h"
      11             : 
      12             : #include "Function.h"
      13             : 
      14             : // Stefan - Boltzmann Constant
      15             : const Real SIGMA = 5.670374419E-8;
      16             : 
      17             : registerMooseObject("HeatTransferApp", SideSetHeatTransferMaterial);
      18             : 
      19             : InputParameters
      20         169 : SideSetHeatTransferMaterial::validParams()
      21             : {
      22         169 :   InputParameters params = InterfaceMaterial::validParams();
      23         169 :   params.addClassDescription("This material constructs the necessary coefficients and properties "
      24             :                              "for SideSetHeatTransferKernel.");
      25         338 :   params.addParam<FunctionName>("conductivity", 0.0, "Heat conductivity in W/m/K.");
      26         338 :   params.addParam<FunctionName>("conductivity_temperature_function",
      27             :                                 "Heat conductivity in W/m/K as a function of temperature.");
      28         338 :   params.addCoupledVar(
      29             :       "gap_temperature",
      30             :       "Coupled Temperature of gap, used for computing temperature dependent conductivity.");
      31         338 :   params.addParam<FunctionName>("gap_length", 1.0, "Total width of gap in m.");
      32         338 :   params.addParam<FunctionName>("Tbulk", 300, "Bulk temperature of gap in K.");
      33         338 :   params.addParam<FunctionName>(
      34         338 :       "h_primary", 0.0, "Convective heat transfer coefficient (primary face) in W/m^2/K.");
      35         338 :   params.addParam<FunctionName>(
      36         338 :       "h_neighbor", 0.0, "Convective heat transfer coefficient (neighbor face) in W/m^2/K.");
      37         338 :   params.addParam<FunctionName>("emissivity_primary", 0.0, "Primary face emissivity.");
      38         338 :   params.addParam<FunctionName>("emissivity_neighbor", 0.0, "Neighbor face emissivity.");
      39         338 :   params.addParam<FunctionName>("reflectivity_primary",
      40             :                                 "Primary face reflectivity, uses (1-emissivity) if not provided.");
      41         338 :   params.addParam<FunctionName>("reflectivity_neighbor",
      42             :                                 "Neighbor face reflectivity, uses (1-emissivity) if not provided.");
      43         169 :   return params;
      44           0 : }
      45             : 
      46          91 : SideSetHeatTransferMaterial::SideSetHeatTransferMaterial(const InputParameters & parameters)
      47             :   : InterfaceMaterial(parameters),
      48         273 :     _kgap(isParamValid("conductivity_temperature_function")
      49         182 :               ? getFunction("conductivity_temperature_function")
      50         160 :               : getFunction("conductivity")),
      51         113 :     _Tk(isCoupled("gap_temperature") ? &coupledValue("gap_temperature") : nullptr),
      52          91 :     _dgap(getFunction("gap_length")),
      53          91 :     _Tb(getFunction("Tbulk")),
      54          91 :     _hp(getFunction("h_primary")),
      55          91 :     _hm(getFunction("h_neighbor")),
      56          91 :     _eps_p(getFunction("emissivity_primary")),
      57          91 :     _eps_m(getFunction("emissivity_neighbor")),
      58         182 :     _rho_p(isParamValid("reflectivity_primary") ? &getFunction("reflectivity_primary") : nullptr),
      59         182 :     _rho_m(isParamValid("reflectivity_neighbor") ? &getFunction("reflectivity_neighbor") : nullptr),
      60          91 :     _cond(declareProperty<Real>("gap_conductance")),
      61          91 :     _Tbulk(declareProperty<Real>("gap_Tbulk")),
      62          91 :     _h_primary(declareProperty<Real>("gap_h_primary")),
      63          91 :     _h_neighbor(declareProperty<Real>("gap_h_neighbor")),
      64          91 :     _emmissivity_eff_primary(declareProperty<Real>("gap_emissivity_eff_primary")),
      65          91 :     _emmissivity_eff_neighbor(declareProperty<Real>("gap_emissivity_eff_neighbor")),
      66          91 :     _sigma(SIGMA)
      67             : {
      68         204 :   if ((parameters.isParamSetByUser("conductivity") ||
      69         273 :        isParamValid("conductivity_temperature_function")) &&
      70         273 :       !parameters.isParamSetByUser("gap_length"))
      71           0 :     paramError("gap_length", "gap_length not set, but conduction term requested.");
      72         273 :   if (parameters.isParamSetByUser("gap_length") &&
      73         204 :       !(parameters.isParamSetByUser("conductivity") ||
      74         135 :         isParamValid("conductivity_temperature_function")))
      75           0 :     paramError("conductivity", "conductivity not set, but conduction term requested.");
      76         273 :   if (isParamValid("conductivity_temperature_function") &&
      77         113 :       parameters.isParamSetByUser("conductivity"))
      78           0 :     paramError("conductivity",
      79             :                "Cannot specify both conductivity and conductivity_temperature_function.");
      80         273 :   if (isParamValid("conductivity_temperature_function") && !_Tk)
      81           0 :     paramError("gap_temperature",
      82             :                "Variable specification for temp needed if specifying a temperature dependent "
      83             :                "conductivity.");
      84             : 
      85         273 :   if (parameters.isParamSetByUser("h_primary") && !parameters.isParamSetByUser("h_neighbor"))
      86           0 :     paramError("h_neighbor", "h_neighbor not set, but convection term requested.");
      87         273 :   if (parameters.isParamSetByUser("h_neighbor") && !parameters.isParamSetByUser("h_primary"))
      88           0 :     paramError("h_primary", "h_primary not set, but convection term requested.");
      89             : 
      90         273 :   if (parameters.isParamSetByUser("emissivity_primary") &&
      91         273 :       !parameters.isParamSetByUser("emissivity_neighbor"))
      92           0 :     paramError("emissivity_neighbor", "emissivity_neighbor not set, but radiation term requested");
      93         273 :   if (parameters.isParamSetByUser("emissivity_neighbor") &&
      94         273 :       !parameters.isParamSetByUser("emissivity_primary"))
      95           0 :     paramError("emissivity_primary", "emissivity_primary not set, but radiation term requested");
      96          91 : }
      97             : 
      98             : void
      99       31617 : SideSetHeatTransferMaterial::computeQpProperties()
     100             : {
     101             :   // Conductance defined as k_{gap}/\delta
     102       31617 :   Real tqp = (_Tk ? (*_Tk)[_qp] : _t);
     103       31617 :   _cond[_qp] = _kgap.value(tqp, _q_point[_qp]) / _dgap.value(_t, _q_point[_qp]);
     104             : 
     105             :   // Convection parameters
     106       31617 :   _Tbulk[_qp] = _Tb.value(_t, _q_point[_qp]);
     107       31617 :   _h_primary[_qp] = _hp.value(_t, _q_point[_qp]);
     108       31617 :   _h_neighbor[_qp] = _hm.value(_t, _q_point[_qp]);
     109             : 
     110             :   // If reflectivity not provided, assume 1 - epsilon
     111       31617 :   Real rhop = (_rho_p ? (*_rho_p).value(_t, _q_point[_qp]) : 1.0 - _eps_p.value(_t, _q_point[_qp]));
     112       31617 :   Real rhom = (_rho_m ? (*_rho_m).value(_t, _q_point[_qp]) : 1.0 - _eps_m.value(_t, _q_point[_qp]));
     113             : 
     114             :   // Compute effective emissivity (primary): \frac{\sigma\epsilon^+(1-\rho^-)}{1-rho^+\rho^-}
     115       31617 :   _emmissivity_eff_primary[_qp] = _sigma * _eps_p.value(_t, _q_point[_qp]) * (1.0 - rhom);
     116       31617 :   if (_emmissivity_eff_primary[_qp] != 0.0) // Making sure we don't devide by zero
     117       31617 :     _emmissivity_eff_primary[_qp] /= 1.0 - rhop * rhom;
     118             : 
     119             :   // Compute effective emissivity (neighbor): \frac{\sigma\epsilon^-(1-\rho^+)}{1-rho^+\rho^-}
     120       31617 :   _emmissivity_eff_neighbor[_qp] = _sigma * _eps_m.value(_t, _q_point[_qp]) * (1.0 - rhop);
     121       31617 :   if (_emmissivity_eff_neighbor[_qp] != 0.0) // Making sure we don't devide by zero
     122       31617 :     _emmissivity_eff_neighbor[_qp] /= 1.0 - rhop * rhom;
     123       31617 : }

Generated by: LCOV version 1.14