LCOV - code coverage report
Current view: top level - src/raybcs - RayBoundaryConditionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #32971 (54bef8) with base c6cf66 Lines: 36 37 97.3 %
Date: 2026-05-29 20:39: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        4377 : RayBoundaryConditionBase::validParams()
      21             : {
      22        4377 :   auto params = RayTracingObject::validParams();
      23        4377 :   params += BoundaryRestrictableRequired::validParams();
      24             : 
      25        8754 :   params.addParam<std::vector<std::string>>("depends_on",
      26             :                                             "Other RayBCs that this RayBC depends on");
      27             : 
      28        4377 :   params.registerBase("RayBoundaryCondition");
      29        4377 :   params.registerSystemAttributeName("RayBoundaryCondition");
      30             : 
      31             :   // We don't currently allow reinits on RayBCs just yet
      32        4377 :   params.suppressParameter<bool>("implicit");
      33             : 
      34        4377 :   return params;
      35           0 : }
      36             : 
      37        2314 : RayBoundaryConditionBase::RayBoundaryConditionBase(const InputParameters & params)
      38             :   : RayTracingObject(params),
      39             :     Restartable(this, "RayBoundaryConditions"),
      40             :     BoundaryRestrictableRequired(this, false), // false for sidesets
      41        2314 :     _current_intersection_point(_trace_ray.currentIntersectionPoint()),
      42        4628 :     _current_bnd_id(_trace_ray.currentBoundaryID())
      43             : {
      44             :   // Add dependencies
      45        4628 :   if (params.isParamSetByUser("depends_on"))
      46         126 :     for (const auto & name : getParam<std::vector<std::string>>("depends_on"))
      47          84 :       dependsOn(name);
      48        2314 : }
      49             : 
      50        2227 : RayBoundaryConditionBase::~RayBoundaryConditionBase() {}
      51             : 
      52             : void
      53        2698 : RayBoundaryConditionBase::changeRayDirection(const Point & direction, const bool skip_changed_check)
      54             : {
      55             :   auto & ray = currentRay();
      56             : 
      57        2698 :   if (!ray->shouldContinue())
      58           2 :     mooseError("Cannot changeRayDirection() for a Ray that should not continue\n\n",
      59           2 :                ray->getInfo());
      60             : 
      61        2696 :   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        2694 :   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        2692 :   ray->changeDirection(direction, Ray::ChangeDirectionKey());
      71        2690 : }
      72             : 
      73             : std::shared_ptr<Ray>
      74        9168 : 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        9168 :       _study.acquireRayDuringTrace(_tid, RayTracingStudy::AcquireMoveDuringTraceKey());
      81        9168 :   ray->setStart(_current_intersection_point, _current_elem, _current_intersected_side);
      82        9168 :   ray->setStartingDirection(direction);
      83             : 
      84        9168 :   return ray;
      85             : }
      86             : 
      87             : void
      88        9168 : RayBoundaryConditionBase::moveRayToBuffer(std::shared_ptr<Ray> & ray)
      89             : {
      90             :   mooseAssert(_study.currentlyPropagating(),
      91             :               "Should not move Rays into buffer while not propagating");
      92             : 
      93        9168 :   _study.moveRayToBufferDuringTrace(ray, _tid, RayTracingStudy::AcquireMoveDuringTraceKey());
      94        9168 : }

Generated by: LCOV version 1.14