LCOV - code coverage report
Current view: top level - src/postprocessors - NormalizedHeatStructureResidualNorm.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 26 27 96.3 %
Date: 2026-05-29 20:41:18 Functions: 5 5 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 "NormalizedHeatStructureResidualNorm.h"
      11             : #include "ThermalSolidProperties.h"
      12             : 
      13             : registerMooseObject("ThermalHydraulicsApp", NormalizedHeatStructureResidualNorm);
      14             : 
      15             : InputParameters
      16        2298 : NormalizedHeatStructureResidualNorm::validParams()
      17             : {
      18        2298 :   InputParameters params = DiscreteVariableResidualNorm::validParams();
      19             : 
      20        2298 :   params.addClassDescription("Computes a normalized residual norm for a heat structure.");
      21             : 
      22        4596 :   params.addRequiredParam<Real>("T_ref", "Reference temperature [K]");
      23        4596 :   params.addRequiredParam<UserObjectName>("solid_properties", "Solid properties object");
      24        4596 :   params.addRequiredParam<PostprocessorName>("ref_elem_size",
      25             :                                              "Reference element size [units vary]");
      26             : 
      27        2298 :   return params;
      28           0 : }
      29             : 
      30        1227 : NormalizedHeatStructureResidualNorm::NormalizedHeatStructureResidualNorm(
      31        1227 :     const InputParameters & parameters)
      32             :   : DiscreteVariableResidualNorm(parameters),
      33        1227 :     _ref_elem_size(getPostprocessorValue("ref_elem_size")),
      34        1227 :     _initialized(false)
      35             : {
      36        1227 : }
      37             : 
      38             : void
      39       20137 : NormalizedHeatStructureResidualNorm::initialize()
      40             : {
      41       20137 :   DiscreteVariableResidualNorm::initialize();
      42             : 
      43             :   // This cannot be done in constructor or initialSetup() due to some solid
      44             :   // properties not being initialized yet.
      45       20137 :   if (!_initialized)
      46             :   {
      47         830 :     _normalization = computeNormalization();
      48         830 :     _initialized = true;
      49             :   }
      50       20137 : }
      51             : 
      52             : Real
      53         830 : NormalizedHeatStructureResidualNorm::computeNormalization() const
      54             : {
      55         830 :   const auto & sp = getUserObject<ThermalSolidProperties>("solid_properties");
      56        1660 :   const auto T_ref = getParam<Real>("T_ref");
      57         830 :   const auto rho_ref = sp.rho_from_T(T_ref);
      58         830 :   const auto cp_ref = sp.cp_from_T(T_ref);
      59             : 
      60         830 :   return rho_ref * cp_ref * T_ref * _ref_elem_size;
      61             : }
      62             : 
      63             : Real
      64       17500 : NormalizedHeatStructureResidualNorm::getValue() const
      65             : {
      66       17500 :   return DiscreteVariableResidualNorm::getValue() / _normalization;
      67             : }

Generated by: LCOV version 1.14