LCOV - code coverage report
Current view: top level - src/raykernels - RayKernelBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 53 54 98.1 %
Date: 2025-09-04 07:56:07 Functions: 8 9 88.9 %
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 "RayKernelBase.h"
      11             : 
      12             : // Local includes
      13             : #include "RayTracingStudy.h"
      14             : #include "TraceRay.h"
      15             : 
      16             : InputParameters
      17        7129 : RayKernelBase::validParams()
      18             : {
      19        7129 :   auto params = RayTracingObject::validParams();
      20        7129 :   params += BlockRestrictable::validParams();
      21        7129 :   params += RandomInterface::validParams();
      22        7129 :   params += MaterialPropertyInterface::validParams();
      23             : 
      24       14258 :   params.addParam<std::vector<std::string>>("depends_on",
      25             :                                             "Other RayKernels that this RayKernel depends on");
      26             : 
      27        7129 :   params.registerBase("RayKernel");
      28        7129 :   params.registerSystemAttributeName("RayKernel");
      29             : 
      30             :   // Allows for a RayKernel to request that it needs a reinit on its segment
      31             :   // We have this so that for RayKernels that still need qps and weights but do not
      32             :   // have any active variables or materials can still call reinitSegment()
      33        7129 :   params.addPrivateParam<bool>("_need_segment_reinit", false);
      34             : 
      35        7129 :   return params;
      36           0 : }
      37             : 
      38        3825 : RayKernelBase::RayKernelBase(const InputParameters & params)
      39             :   : RayTracingObject(params),
      40             :     CoupleableMooseVariableDependencyIntermediateInterface(this, false),
      41             :     BlockRestrictable(this),
      42        3825 :     RandomInterface(params, _fe_problem, _tid, false),
      43             :     MaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS),
      44             :     Restartable(this, "RayKernels"),
      45        3825 :     _current_segment_start(_trace_ray.currentIncomingPoint()),
      46        3825 :     _current_segment_end(_trace_ray.currentIntersectionPoint()),
      47        3825 :     _current_segment_length(_trace_ray.currentIntersectionDistance()),
      48        3825 :     _current_incoming_side(_trace_ray.currentIncomingSide()),
      49       11475 :     _need_segment_reinit(getParam<bool>("_need_segment_reinit"))
      50             : {
      51             :   // Add dependencies
      52        7650 :   if (isParamValid("depends_on"))
      53         243 :     for (const auto & name : getParam<std::vector<std::string>>("depends_on"))
      54         162 :       dependsOn(name);
      55             : 
      56             :   // Stateful material properties are not allowed on RayKernels
      57        3825 :   statefulPropertiesAllowed(false);
      58        3825 : }
      59             : 
      60        3738 : RayKernelBase::~RayKernelBase() {}
      61             : 
      62             : void
      63         662 : RayKernelBase::changeRayStartDirection(const Point & start, const Point & direction)
      64             : {
      65             :   mooseAssert(_study.currentlyPropagating(), "Should not change Ray outside of tracing");
      66             : 
      67             :   const auto & ray = currentRay();
      68             : 
      69         662 :   if (!ray->shouldContinue())
      70             :   {
      71           4 :     if (ray->endSet() && ray->atEnd())
      72           2 :       mooseError("Cannot changeRayStartDirection() for a Ray that should not continue.\n\n",
      73             :                  "It has also hit its user-set end point.\n\n",
      74           2 :                  ray->getInfo());
      75             :     else
      76           2 :       mooseError("Cannot changeRayStartDirection() for a Ray that should not continue.\n\n",
      77           2 :                  ray->getInfo());
      78             :   }
      79             : 
      80         658 :   if (ray->trajectoryChanged())
      81           2 :     mooseError("Cannot change a Ray's trajectory when its trajectory has already been changed\n\n",
      82           2 :                ray->getInfo());
      83             : 
      84         656 :   if (ray->endSet())
      85           2 :     mooseError("Cannot change the direction of a Ray whose end point is set upon generation "
      86             :                "(via setStartingEndPoint()).\n\n",
      87           2 :                ray->getInfo());
      88             : 
      89         654 :   if (_study.verifyRays() && !_current_elem->contains_point(start))
      90           2 :     mooseError("A Ray's start point was changed within a RayKernel, and said start point\n",
      91             :                "is not within the element that the RayKernel was executed on.\n\n",
      92           2 :                ray->getInfo());
      93             : 
      94         652 :   ray->changeStartDirection(start, direction, Ray::ChangeStartDirectionKey());
      95         650 : }
      96             : 
      97             : std::shared_ptr<Ray>
      98       68688 : RayKernelBase::acquireRay(const Point & start, const Point & direction)
      99             : {
     100             :   mooseAssert(_study.currentlyPropagating(), "Should not be getting a Ray while not propagating");
     101             : 
     102             :   // Acquire a Ray with the proper sizes and a unique ID, and set the start info
     103             :   std::shared_ptr<Ray> ray =
     104       68688 :       _study.acquireRayDuringTrace(_tid, RayTracingStudy::AcquireMoveDuringTraceKey());
     105       68688 :   ray->setStart(start, _current_elem, RayTracingCommon::invalid_side);
     106       68688 :   ray->setStartingDirection(direction);
     107             : 
     108       68688 :   return ray;
     109             : }
     110             : 
     111             : void
     112       68688 : RayKernelBase::moveRayToBuffer(std::shared_ptr<Ray> & ray)
     113             : {
     114             :   mooseAssert(_study.currentlyPropagating(),
     115             :               "Should not move Rays into buffer while not propagating");
     116             : 
     117       68688 :   _study.moveRayToBufferDuringTrace(ray, _tid, RayTracingStudy::AcquireMoveDuringTraceKey());
     118       68688 : }
     119             : 
     120             : void
     121     4962123 : RayKernelBase::preTrace()
     122             : {
     123     4962123 : }
     124             : 
     125             : void
     126     3795928 : RayKernelBase::postTrace()
     127             : {
     128     3795928 : }

Generated by: LCOV version 1.14