LCOV - code coverage report
Current view: top level - src/postprocessors - RayIntegralValue.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 32 33 97.0 %
Date: 2025-09-04 07:56:07 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             : // MOOSE includes
      11             : #include "RayIntegralValue.h"
      12             : 
      13             : // Local includes
      14             : #include "IntegralRayKernel.h"
      15             : #include "RayTracingStudy.h"
      16             : 
      17             : registerMooseObject("RayTracingApp", RayIntegralValue);
      18             : 
      19             : InputParameters
      20        1654 : RayIntegralValue::validParams()
      21             : {
      22        1654 :   InputParameters params = GeneralPostprocessor::validParams();
      23             : 
      24        1654 :   params.addClassDescription("Obtains the integrated value accumulated into a Ray from an "
      25             :                              "IntegralRayKernel-derived class.");
      26             : 
      27        3308 :   params.addRequiredParam<std::string>("ray",
      28             :                                        "Name of the Ray to get the final integral value from");
      29        3308 :   params.addRequiredParam<std::string>(
      30             :       "ray_kernel",
      31             :       "The name of the IntegralRayKernel-derived RayKernel to obtain the integral value of");
      32             : 
      33        1654 :   return params;
      34           0 : }
      35             : 
      36         827 : RayIntegralValue::RayIntegralValue(const InputParameters & parameters)
      37         827 :   : GeneralPostprocessor(parameters), _study(nullptr)
      38             : {
      39         827 : }
      40             : 
      41             : void
      42         612 : RayIntegralValue::initialize()
      43             : {
      44             :   // Look for the IntegralRayKernel by the name provided by the user
      45             :   const IntegralRayKernel * integral_ray_kernel = nullptr;
      46             :   std::vector<RayKernelBase *> rks;
      47        1224 :   _fe_problem.theWarehouse().query().condition<AttribSystem>("RayKernel").queryInto(rks);
      48         751 :   for (const RayKernelBase * rk : rks)
      49        1498 :     if (rk->name() == getParam<std::string>("ray_kernel"))
      50             :     {
      51         610 :       integral_ray_kernel = dynamic_cast<const IntegralRayKernel *>(rk);
      52         610 :       if (!integral_ray_kernel)
      53           2 :         mooseError(rk->type(), " is not derived from an IntegralRayKernel.");
      54         608 :       _study = &rk->study();
      55         608 :       break;
      56             :     }
      57             : 
      58             :   // Didn't find one
      59         610 :   if (!integral_ray_kernel)
      60           4 :     paramError("ray_kernel",
      61             :                "The RayKernel by the name '",
      62             :                getParam<std::string>("ray_kernel"),
      63             :                "' was not found.");
      64             : 
      65             :   // This requires that our studies use Ray name registration
      66         608 :   if (!_study->useRayRegistration())
      67           2 :     mooseError("Cannot be used because the supplied ",
      68             :                _study->type(),
      69             :                " does not have Ray registration enabled.\n\nThis is controlled by the "
      70             :                "RayTracingStudy private param '_use_ray_registration'.");
      71             :   // And also that the Rays are banked, otherwise we can't grab the values
      72         606 :   if (!_study->bankRaysOnCompletion())
      73           2 :     mooseError("Cannot be used because the supplied ",
      74             :                _study->type(),
      75             :                " does not bank Rays on completion.\n\nThis is controlled by the RayTracingStudy "
      76             :                "private param '_bank_rays_on_completion'.");
      77             : 
      78             :   // Get the Ray ID
      79         604 :   const auto & ray_name = getParam<std::string>("ray");
      80         604 :   _ray_id = _study->registeredRayID(ray_name, /* graceful = */ true);
      81         604 :   if (_ray_id == Ray::INVALID_RAY_ID)
      82           2 :     paramError("ray", "Could not find a Ray named '", ray_name, "'");
      83             : 
      84             :   // Get the index for the data on the ray requested
      85         602 :   _ray_data_index = _study->getRayDataIndex(integral_ray_kernel->integralRayDataName());
      86         602 : }
      87             : 
      88             : Real
      89         602 : RayIntegralValue::getValue() const
      90             : {
      91             :   // This gathers the value from the proc that killed the Ray we're looking for
      92         602 :   return _study->getBankedRayData(_ray_id, _ray_data_index);
      93             : }

Generated by: LCOV version 1.14