LCOV - code coverage report
Current view: top level - src/materials - ADAverageWallTemperature3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 40 41 97.6 %
Date: 2025-07-30 13:02:48 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 "ADAverageWallTemperature3EqnMaterial.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", ADAverageWallTemperature3EqnMaterial);
      13             : 
      14             : InputParameters
      15         296 : ADAverageWallTemperature3EqnMaterial::validParams()
      16             : {
      17         296 :   InputParameters params = Material::validParams();
      18             : 
      19         296 :   params.addClassDescription(
      20             :       "Weighted average wall temperature from multiple sources for 1-phase flow");
      21             : 
      22         592 :   params.addRequiredCoupledVar("T_wall_sources",
      23             :                                "Vector of wall temperatures from individual sources");
      24         592 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      25             :       "Hw_sources", "Vector of wall heat transfer coefficients from individual sources");
      26         592 :   params.addRequiredCoupledVar("P_hf_sources",
      27             :                                "Vector of heated perimeters from individual sources");
      28         592 :   params.addRequiredCoupledVar("T_fluid", "Fluid temperature");
      29         592 :   params.addRequiredCoupledVar("P_hf_total", "Total heat flux perimeter from all sources");
      30             : 
      31         296 :   return params;
      32           0 : }
      33             : 
      34         232 : ADAverageWallTemperature3EqnMaterial::ADAverageWallTemperature3EqnMaterial(
      35         232 :     const InputParameters & parameters)
      36             :   : Material(parameters),
      37         232 :     _T_wall(declareADProperty<Real>("T_wall")),
      38         232 :     _n_values(coupledComponents("T_wall_sources")),
      39         232 :     _T_fluid(adCoupledValue("T_fluid")),
      40         696 :     _P_hf_total(adCoupledValue("P_hf_total"))
      41             : {
      42             :   // make sure that numbers of values are consistent
      43         464 :   if (getParam<std::vector<MaterialPropertyName>>("Hw_sources").size() != _n_values)
      44           2 :     mooseError(name(),
      45             :                ": The number of wall heat transfer coefficient values"
      46             :                " must equal the number of wall temperature values");
      47         230 :   if (coupledComponents("P_hf_sources") != _n_values)
      48           2 :     mooseError(name(),
      49             :                ": The number of heated perimeter values"
      50             :                " must equal the number of wall temperature values");
      51             : 
      52             :   // get all of the variable values
      53             :   const std::vector<MaterialPropertyName> & Hw_prop_names =
      54         228 :       getParam<std::vector<MaterialPropertyName>>("Hw_sources");
      55         684 :   for (unsigned int i = 0; i < _n_values; i++)
      56             :   {
      57         456 :     _T_wall_sources.push_back(&adCoupledValue("T_wall_sources", i));
      58         456 :     _Hw_sources.push_back(&getADMaterialProperty<Real>(Hw_prop_names[i]));
      59         912 :     _P_hf_sources.push_back(&adCoupledValue("P_hf_sources", i));
      60             :   }
      61         228 : }
      62             : 
      63             : void
      64       57138 : ADAverageWallTemperature3EqnMaterial::computeQpProperties()
      65             : {
      66       57138 :   ADReal denominator = 0;
      67      171414 :   for (unsigned int i = 0; i < _n_values; i++)
      68      228552 :     denominator += (*(_Hw_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      69             : 
      70       57138 :   if (std::abs(denominator) < 1e-15)
      71             :   {
      72             :     // use alternate definition to avoid division by zero: heated-perimeter-weighted average
      73          72 :     ADReal numerator = 0;
      74         216 :     for (unsigned int i = 0; i < _n_values; i++)
      75         288 :       numerator += (*(_T_wall_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      76         144 :     _T_wall[_qp] = numerator / _P_hf_total[_qp];
      77             :   }
      78             :   else
      79             :   {
      80             :     // use normal definition
      81       57066 :     ADReal numerator = 0;
      82      171198 :     for (unsigned int i = 0; i < _n_values; i++)
      83      342396 :       numerator += (*(_Hw_sources[i]))[_qp] * ((*(_T_wall_sources[i]))[_qp] - _T_fluid[_qp]) *
      84      228264 :                    (*(_P_hf_sources[i]))[_qp];
      85      114132 :     _T_wall[_qp] = _T_fluid[_qp] + numerator / denominator;
      86             :   }
      87       57138 : }

Generated by: LCOV version 1.14