LCOV - code coverage report
Current view: top level - src/raybcs - RayBoundaryConditionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 36 37 97.3 %
Date: 2025-09-04 07:56:07 Functions: 6 7 85.7 %
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 "RayBoundaryConditionBase.h"
      11             : 
      12             : // Local includes
      13             : #include "RayTracingStudy.h"
      14             : #include "TraceRay.h"
      15             : 
      16             : // MOOSE includes
      17             : #include "Assembly.h"
      18             : 
      19             : InputParameters
      20        8558 : RayBoundaryConditionBase::validParams()
      21             : {
      22        8558 :   auto params = RayTracingObject::validParams();
      23        8558 :   params += BoundaryRestrictableRequired::validParams();
      24             : 
      25       17116 :   params.addParam<std::vector<std::string>>("depends_on",
      26             :                                             "Other RayBCs that this RayBC depends on");
      27             : 
      28        8558 :   params.registerBase("RayBoundaryCondition");
      29        8558 :   params.registerSystemAttributeName("RayBoundaryCondition");
      30             : 
      31             :   // We don't currently allow reinits on RayBCs just yet
      32        8558 :   params.suppressParameter<bool>("implicit");
      33             : 
      34        8558 :   return params;
      35           0 : }
      36             : 
      37        4618 : RayBoundaryConditionBase::RayBoundaryConditionBase(const InputParameters & params)
      38             :   : RayTracingObject(params),
      39             :     Restartable(this, "RayBoundaryConditions"),
      40             :     BoundaryRestrictableRequired(this, false), // false for sidesets
      41        4618 :     _current_intersection_point(_trace_ray.currentIntersectionPoint()),
      42        9236 :     _current_bnd_id(_trace_ray.currentBoundaryID())
      43             : {
      44             :   // Add dependencies
      45        9236 :   if (params.isParamSetByUser("depends_on"))
      46         234 :     for (const auto & name : getParam<std::vector<std::string>>("depends_on"))
      47         156 :       dependsOn(name);
      48        4618 : }
      49             : 
      50        4537 : RayBoundaryConditionBase::~RayBoundaryConditionBase() {}
      51             : 
      52             : void
      53        4069 : RayBoundaryConditionBase::changeRayDirection(const Point & direction, const bool skip_changed_check)
      54             : {
      55             :   auto & ray = currentRay();
      56             : 
      57        4069 :   if (!ray->shouldContinue())
      58           2 :     mooseError("Cannot changeRayDirection() for a Ray that should not continue\n\n",
      59           2 :                ray->getInfo());
      60             : 
      61        4067 :   if (!skip_changed_check && ray->trajectoryChanged())
      62           2 :     mooseError("Cannot change direction for a ray whose direction has already been changed\n\n",
      63           2 :                ray->getInfo());
      64             : 
      65        4065 :   if (ray->endSet())
      66           2 :     mooseError("Cannot change the direction of a Ray whose end point is set upon generation "
      67             :                "(via setStartingEndPoint()).\n\n",
      68           2 :                ray->getInfo());
      69             : 
      70        4063 :   ray->changeDirection(direction, Ray::ChangeDirectionKey());
      71        4061 : }
      72             : 
      73             : std::shared_ptr<Ray>
      74       13752 : RayBoundaryConditionBase::acquireRay(const Point & direction)
      75             : {
      76             :   mooseAssert(_study.currentlyPropagating(), "Should not be getting a Ray while not propagating");
      77             : 
      78             :   // Acquire a Ray with the proper sizes and a unique ID, and set the start info
      79             :   std::shared_ptr<Ray> ray =
      80       13752 :       _study.acquireRayDuringTrace(_tid, RayTracingStudy::AcquireMoveDuringTraceKey());
      81       13752 :   ray->setStart(_current_intersection_point, _current_elem, _current_intersected_side);
      82       13752 :   ray->setStartingDirection(direction);
      83             : 
      84       13752 :   return ray;
      85             : }
      86             : 
      87             : void
      88       13752 : RayBoundaryConditionBase::moveRayToBuffer(std::shared_ptr<Ray> & ray)
      89             : {
      90             :   mooseAssert(_study.currentlyPropagating(),
      91             :               "Should not move Rays into buffer while not propagating");
      92             : 
      93       13752 :   _study.moveRayToBufferDuringTrace(ray, _tid, RayTracingStudy::AcquireMoveDuringTraceKey());
      94       13752 : }

Generated by: LCOV version 1.14