LCOV - code coverage report
Current view: top level - src/materials - AverageWallTemperature3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 37 38 97.4 %
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 "AverageWallTemperature3EqnMaterial.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", AverageWallTemperature3EqnMaterial);
      13             : 
      14             : InputParameters
      15         174 : AverageWallTemperature3EqnMaterial::validParams()
      16             : {
      17         174 :   InputParameters params = Material::validParams();
      18             : 
      19         174 :   params.addClassDescription(
      20             :       "Weighted average wall temperature from multiple sources for 1-phase flow");
      21             : 
      22         348 :   params.addRequiredCoupledVar("T_wall_sources",
      23             :                                "Vector of wall temperatures from individual sources");
      24         348 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      25             :       "Hw_sources", "Vector of wall heat transfer coefficients from individual sources");
      26         348 :   params.addRequiredCoupledVar("P_hf_sources",
      27             :                                "Vector of heated perimeters from individual sources");
      28         348 :   params.addRequiredCoupledVar("T_fluid", "Fluid temperature");
      29         348 :   params.addRequiredCoupledVar("P_hf_total", "Total heat flux perimeter from all sources");
      30             : 
      31         174 :   return params;
      32           0 : }
      33             : 
      34         136 : AverageWallTemperature3EqnMaterial::AverageWallTemperature3EqnMaterial(
      35         136 :     const InputParameters & parameters)
      36             :   : Material(parameters),
      37         136 :     _T_wall(declareProperty<Real>("T_wall")),
      38         136 :     _n_values(coupledComponents("T_wall_sources")),
      39         136 :     _T_fluid(coupledValue("T_fluid")),
      40         408 :     _P_hf_total(coupledValue("P_hf_total"))
      41             : {
      42             :   // make sure that numbers of values are consistent
      43         272 :   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         134 :   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         132 :       getParam<std::vector<MaterialPropertyName>>("Hw_sources");
      55         396 :   for (unsigned int i = 0; i < _n_values; i++)
      56             :   {
      57         264 :     _T_wall_sources.push_back(&coupledValue("T_wall_sources", i));
      58         264 :     _Hw_sources.push_back(&getMaterialProperty<Real>(Hw_prop_names[i]));
      59         528 :     _P_hf_sources.push_back(&coupledValue("P_hf_sources", i));
      60             :   }
      61         132 : }
      62             : 
      63             : void
      64         108 : AverageWallTemperature3EqnMaterial::computeQpProperties()
      65             : {
      66             :   Real denominator = 0;
      67         324 :   for (unsigned int i = 0; i < _n_values; i++)
      68         216 :     denominator += (*(_Hw_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      69             : 
      70         108 :   if (std::abs(denominator) < 1e-15)
      71             :   {
      72             :     // use alternate definition to avoid division by zero: heated-perimeter-weighted average
      73             :     Real numerator = 0;
      74         216 :     for (unsigned int i = 0; i < _n_values; i++)
      75         144 :       numerator += (*(_T_wall_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      76          72 :     _T_wall[_qp] = numerator / _P_hf_total[_qp];
      77             :   }
      78             :   else
      79             :   {
      80             :     // use normal definition
      81             :     Real numerator = 0;
      82         108 :     for (unsigned int i = 0; i < _n_values; i++)
      83          72 :       numerator += (*(_Hw_sources[i]))[_qp] * ((*(_T_wall_sources[i]))[_qp] - _T_fluid[_qp]) *
      84          72 :                    (*(_P_hf_sources[i]))[_qp];
      85          36 :     _T_wall[_qp] = _T_fluid[_qp] + numerator / denominator;
      86             :   }
      87         108 : }

Generated by: LCOV version 1.14