LCOV - code coverage report
Current view: top level - src/userobjects - ConstantViewFactorSurfaceRadiation.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 27 30 90.0 %
Date: 2025-09-04 07:53:51 Functions: 4 4 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 "ConstantViewFactorSurfaceRadiation.h"
      11             : 
      12             : registerMooseObject("HeatTransferApp", ConstantViewFactorSurfaceRadiation);
      13             : 
      14             : InputParameters
      15         141 : ConstantViewFactorSurfaceRadiation::validParams()
      16             : {
      17         141 :   InputParameters params = GrayLambertSurfaceRadiationBase::validParams();
      18         282 :   params.addRequiredParam<std::vector<std::vector<Real>>>(
      19             :       "view_factors", "The view factors from sideset i to sideset j.");
      20         141 :   params.addClassDescription(
      21             :       "ConstantViewFactorSurfaceRadiation computes radiative heat transfer between side sets and "
      22             :       "the view factors are provided in the input file");
      23         141 :   return params;
      24           0 : }
      25             : 
      26          80 : ConstantViewFactorSurfaceRadiation::ConstantViewFactorSurfaceRadiation(
      27          80 :     const InputParameters & parameters)
      28          80 :   : GrayLambertSurfaceRadiationBase(parameters)
      29             : {
      30          72 : }
      31             : 
      32             : std::vector<std::vector<Real>>
      33        5820 : ConstantViewFactorSurfaceRadiation::setViewFactors()
      34             : {
      35       17460 :   std::vector<std::vector<Real>> vf = getParam<std::vector<std::vector<Real>>>("view_factors");
      36             : 
      37             :   // check that the input has the right format
      38        5820 :   if (vf.size() != _n_sides)
      39           2 :     paramError("view_factors",
      40             :                "Leading dimension of view_factors must be equal to number of side sets.");
      41             : 
      42       29084 :   for (unsigned int i = 0; i < _n_sides; ++i)
      43       23268 :     if (vf[i].size() != _n_sides)
      44           2 :       paramError("view_factors",
      45             :                  "view_factors must be provided as square array. Row ",
      46             :                  i,
      47             :                  " has ",
      48             :                  vf[i].size(),
      49             :                  " entries.");
      50        5816 :   return vf;
      51           0 : }
      52             : 
      53             : void
      54        5820 : ConstantViewFactorSurfaceRadiation::initialize()
      55             : {
      56        5820 :   GrayLambertSurfaceRadiationBase::initialize();
      57             : 
      58             :   // check row-sum and normalize if necessary
      59       29080 :   for (unsigned int i = 0; i < _n_sides; ++i)
      60             :   {
      61       23264 :     Real sum = 0;
      62      116320 :     for (auto & v : _view_factors[i])
      63       93056 :       sum += v;
      64             : 
      65             :     // an error of 5% is acceptable, but more indicates an error in the
      66             :     // problem setup
      67       23264 :     if (std::abs(sum - 1) > 0.05)
      68           0 :       mooseError("view_factors row ", i, " sums to ", sum);
      69             : 
      70             :     // correct view factors
      71      116320 :     for (auto & v : _view_factors[i])
      72       93056 :       v /= sum;
      73             :   }
      74        5816 : }

Generated by: LCOV version 1.14