LCOV - code coverage report
Current view: top level - src/materials - ADAverageWallTemperature3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 40 41 97.6 %
Date: 2026-05-29 20:41:18 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         144 : ADAverageWallTemperature3EqnMaterial::validParams()
      16             : {
      17         144 :   InputParameters params = Material::validParams();
      18             : 
      19         144 :   params.addClassDescription(
      20             :       "Weighted average wall temperature from multiple sources for 1-phase flow");
      21             : 
      22         288 :   params.addRequiredCoupledVar("T_wall_sources",
      23             :                                "Vector of wall temperatures from individual sources");
      24         288 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      25             :       "Hw_sources", "Vector of wall heat transfer coefficients from individual sources");
      26         288 :   params.addRequiredCoupledVar("P_hf_sources",
      27             :                                "Vector of heated perimeters from individual sources");
      28         288 :   params.addRequiredCoupledVar("T_fluid", "Fluid temperature");
      29         288 :   params.addRequiredCoupledVar("P_hf_total", "Total heat flux perimeter from all sources");
      30             : 
      31         144 :   return params;
      32           0 : }
      33             : 
      34         112 : ADAverageWallTemperature3EqnMaterial::ADAverageWallTemperature3EqnMaterial(
      35         112 :     const InputParameters & parameters)
      36             :   : Material(parameters),
      37         112 :     _T_wall(declareADProperty<Real>("T_wall")),
      38         112 :     _n_values(coupledComponents("T_wall_sources")),
      39         112 :     _T_fluid(adCoupledValue("T_fluid")),
      40         224 :     _P_hf_total(adCoupledValue("P_hf_total"))
      41             : {
      42             :   // make sure that numbers of values are consistent
      43         224 :   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         110 :   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         108 :       getParam<std::vector<MaterialPropertyName>>("Hw_sources");
      55         324 :   for (unsigned int i = 0; i < _n_values; i++)
      56             :   {
      57         216 :     _T_wall_sources.push_back(&adCoupledValue("T_wall_sources", i));
      58         216 :     _Hw_sources.push_back(&getADMaterialProperty<Real>(Hw_prop_names[i]));
      59         432 :     _P_hf_sources.push_back(&adCoupledValue("P_hf_sources", i));
      60             :   }
      61         108 : }
      62             : 
      63             : void
      64       51682 : ADAverageWallTemperature3EqnMaterial::computeQpProperties()
      65             : {
      66             :   using std::abs;
      67             : 
      68       51682 :   ADReal denominator = 0;
      69      155046 :   for (unsigned int i = 0; i < _n_values; i++)
      70      206728 :     denominator += (*(_Hw_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      71             : 
      72       51682 :   if (abs(denominator) < 1e-15)
      73             :   {
      74             :     // use alternate definition to avoid division by zero: heated-perimeter-weighted average
      75          48 :     ADReal numerator = 0;
      76         144 :     for (unsigned int i = 0; i < _n_values; i++)
      77         192 :       numerator += (*(_T_wall_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
      78          96 :     _T_wall[_qp] = numerator / _P_hf_total[_qp];
      79             :   }
      80             :   else
      81             :   {
      82             :     // use normal definition
      83       51634 :     ADReal numerator = 0;
      84      154902 :     for (unsigned int i = 0; i < _n_values; i++)
      85      309804 :       numerator += (*(_Hw_sources[i]))[_qp] * ((*(_T_wall_sources[i]))[_qp] - _T_fluid[_qp]) *
      86      206536 :                    (*(_P_hf_sources[i]))[_qp];
      87      103268 :     _T_wall[_qp] = _T_fluid[_qp] + numerator / denominator;
      88             :   }
      89       51682 : }

Generated by: LCOV version 1.14