LCOV - code coverage report
Current view: top level - src/raykernels - LineSourceRayKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #32971 (54bef8) with base c6cf66 Lines: 25 26 96.2 %
Date: 2026-05-29 20:39: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         315 : LineSourceRayKernelTempl<is_ad>::validParams()
      21             : {
      22             :   InputParameters params = GenericRayKernel<is_ad>::validParams();
      23             : 
      24         315 :   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         630 :   params.addParam<Real>("value", 1.0, "Coefficient to multiply by the line source term");
      30         630 :   params.addParam<FunctionName>("function", "1", "A function that describes the line source");
      31         630 :   params.addParam<PostprocessorName>(
      32         630 :       "postprocessor", 1, "A postprocessor whose value is multiplied by the line source");
      33         630 :   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         630 :   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         630 :   params.declareControllable("value");
      41             : 
      42         315 :   return params;
      43           0 : }
      44             : 
      45             : template <bool is_ad>
      46         169 : LineSourceRayKernelTempl<is_ad>::LineSourceRayKernelTempl(const InputParameters & params)
      47             :   : GenericRayKernel<is_ad>(params),
      48         163 :     _scale(this->template getParam<Real>("value")),
      49         163 :     _function(getFunction("function")),
      50         163 :     _postprocessor(getPostprocessorValue("postprocessor")),
      51         326 :     _ray_data_factor_indices(this->_study.getRayDataIndices(
      52             :         this->template getParam<std::vector<std::string>>("ray_data_factor_names"))),
      53         326 :     _ray_aux_data_factor_indices(this->_study.getRayAuxDataIndices(
      54         169 :         this->template getParam<std::vector<std::string>>("ray_aux_data_factor_names")))
      55             : {
      56         163 : }
      57             : 
      58             : template <bool is_ad>
      59             : GenericReal<is_ad>
      60      309296 : LineSourceRayKernelTempl<is_ad>::computeQpResidual()
      61             : {
      62      309296 :   Real factor = _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
      63             : 
      64             :   // Scale by any Ray data and aux data if given
      65      604216 :   for (const auto index : _ray_data_factor_indices)
      66      294920 :     factor *= currentRay()->data(index);
      67      309880 :   for (const auto index : _ray_aux_data_factor_indices)
      68         584 :     factor *= currentRay()->auxData(index);
      69             : 
      70      309296 :   return _test[_i][_qp] * -factor;
      71             : }
      72             : 
      73             : template class LineSourceRayKernelTempl<false>;
      74             : template class LineSourceRayKernelTempl<true>;

Generated by: LCOV version 1.14