LCOV - code coverage report
Current view: top level - src/raykernels - LineSourceRayKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 25 26 96.2 %
Date: 2025-09-04 07:56:07 Functions: 6 6 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 "LineSourceRayKernel.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "Function.h"
      14             : 
      15             : registerMooseObject("RayTracingApp", LineSourceRayKernel);
      16             : registerMooseObject("RayTracingApp", ADLineSourceRayKernel);
      17             : 
      18             : template <bool is_ad>
      19             : InputParameters
      20         667 : LineSourceRayKernelTempl<is_ad>::validParams()
      21             : {
      22             :   InputParameters params = GenericRayKernel<is_ad>::validParams();
      23             : 
      24         667 :   params.addClassDescription(
      25             :       "Demonstrates the multiple ways that scalar values can be introduced "
      26             :       "into RayKernels, e.g. (controllable) constants, functions, "
      27             :       "postprocessors, and data on rays. Implements the weak form $(\\psi_i, -f)$ along a line.");
      28             : 
      29        1334 :   params.addParam<Real>("value", 1.0, "Coefficient to multiply by the line source term");
      30        1334 :   params.addParam<FunctionName>("function", "1", "A function that describes the line source");
      31        1334 :   params.addParam<PostprocessorName>(
      32        1334 :       "postprocessor", 1, "A postprocessor whose value is multiplied by the line source");
      33        1334 :   params.addParam<std::vector<std::string>>(
      34             :       "ray_data_factor_names", {}, "The names of the Ray data to scale the source by (if any)");
      35        1334 :   params.addParam<std::vector<std::string>>(
      36             :       "ray_aux_data_factor_names",
      37             :       {},
      38             :       "The names of the Ray aux data to scale the source by (if any)");
      39             : 
      40        1334 :   params.declareControllable("value");
      41             : 
      42         667 :   return params;
      43           0 : }
      44             : 
      45             : template <bool is_ad>
      46         361 : LineSourceRayKernelTempl<is_ad>::LineSourceRayKernelTempl(const InputParameters & params)
      47             :   : GenericRayKernel<is_ad>(params),
      48         355 :     _scale(this->template getParam<Real>("value")),
      49         355 :     _function(getFunction("function")),
      50         355 :     _postprocessor(getPostprocessorValue("postprocessor")),
      51         710 :     _ray_data_factor_indices(this->_study.getRayDataIndices(
      52             :         this->template getParam<std::vector<std::string>>("ray_data_factor_names"))),
      53         710 :     _ray_aux_data_factor_indices(this->_study.getRayAuxDataIndices(
      54         361 :         this->template getParam<std::vector<std::string>>("ray_aux_data_factor_names")))
      55             : {
      56         355 : }
      57             : 
      58             : template <bool is_ad>
      59             : GenericReal<is_ad>
      60      474240 : LineSourceRayKernelTempl<is_ad>::computeQpResidual()
      61             : {
      62      474240 :   Real factor = _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
      63             : 
      64             :   // Scale by any Ray data and aux data if given
      65      926736 :   for (const auto index : _ray_data_factor_indices)
      66      452496 :     factor *= currentRay()->data(index);
      67      475128 :   for (const auto index : _ray_aux_data_factor_indices)
      68         888 :     factor *= currentRay()->auxData(index);
      69             : 
      70      474240 :   return _test[_i][_qp] * -factor;
      71             : }
      72             : 
      73             : template class LineSourceRayKernelTempl<false>;
      74             : template class LineSourceRayKernelTempl<true>;

Generated by: LCOV version 1.14