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 : #pragma once 11 : 12 : // Local Includes 13 : #include "RayTracingObject.h" 14 : 15 : // MOOSE includes 16 : #include "CoupleableMooseVariableDependencyIntermediateInterface.h" 17 : #include "BlockRestrictable.h" 18 : #include "RandomInterface.h" 19 : #include "MaterialPropertyInterface.h" 20 : #include "Restartable.h" 21 : 22 : /** 23 : * Base object for the RayKernel syntax 24 : * 25 : * Operates on Ray segments 26 : */ 27 : class RayKernelBase : public RayTracingObject, 28 : public CoupleableMooseVariableDependencyIntermediateInterface, 29 : public BlockRestrictable, 30 : public RandomInterface, 31 : public MaterialPropertyInterface, 32 : public Restartable 33 : { 34 : public: 35 : RayKernelBase(const InputParameters & params); 36 : virtual ~RayKernelBase(); 37 : 38 : static InputParameters validParams(); 39 : 40 : /** 41 : * Called on each segment of a Ray 42 : * 43 : * Important information available during onSegment(): 44 : * currentRay() - The current Ray that is being traced on the segment 45 : * _current_elem - The current Elem the Ray is tracing in 46 : * _current_segment_start - The start point of the segment 47 : * _current_segment_end - The end point of the segment 48 : * _current_segment_length - The length of the segment 49 : * _current_intersected_side - The side intersected on _current_elem (if any) 50 : * _current_intersected_extrema - The extrema (vertex/edge) intersected on 51 : * _current_elem (if any) 52 : * _current_incoming_side - The side of _current_elem that _current_segment_start 53 : * is on (if any) 54 : */ 55 : virtual void onSegment() = 0; 56 : 57 : /** 58 : * Called at the beginning of the trace on this processor/thread for a Ray 59 : * 60 : * This is not only called at the _true_ beginning of the Ray, but instead 61 : * it is called every time this processor/thread starts the trace for the 62 : * part it can trace 63 : */ 64 : virtual void preTrace(); 65 : 66 : /** 67 : * This method is called once a ray has reached the end of its trace. 68 : */ 69 : virtual void postTrace(); 70 : 71 : /** 72 : * Whether or not this RayKernel needs a segment reinit 73 : */ 74 33719796 : bool needSegmentReinit() const { return _need_segment_reinit; } 75 : 76 : protected: 77 : /** 78 : * Changes the current Ray's start point and direction. 79 : * 80 : * The start point must be within the current element. 81 : */ 82 : void changeRayStartDirection(const Point & start, const Point & direction); 83 : 84 : /** 85 : * Acquires a Ray to be used for generating a new Ray while tracing on the boundary. 86 : * 87 : * Appropriately sets the information needed: 88 : * - Sizes the Ray's data to the size needed by the study 89 : * - Sets the starting elem to the current element 90 : * - Sets the start point to \p start 91 : * - Sets the direction as provided by \p direction 92 : * - Sets the RayID to something unique 93 : */ 94 : std::shared_ptr<Ray> acquireRay(const Point & start, const Point & direction); 95 : 96 : /** 97 : * Moves a Ray into the working buffer to be traced during tracing with a 98 : * meaningful error on verification failure 99 : */ 100 : void moveRayToBuffer(std::shared_ptr<Ray> & ray); 101 : 102 : /// The start point of the current Ray's segment 103 : const Point & _current_segment_start; 104 : /// The end point of the current Ray's segment 105 : const Point & _current_segment_end; 106 : /// The length of the current Ray's segment 107 : const Real & _current_segment_length; 108 : /// The current side of _current_elem that _current_segment_start is on (if any) 109 : const unsigned short & _current_incoming_side; 110 : 111 : /// Whether or not this RayKernel needs a segment reinit 112 : const bool _need_segment_reinit; 113 : }; 114 : 115 : #define usingRayKernelBaseMembers \ 116 : usingRayTracingObjectMembers; \ 117 : usingBlockRestrictableMembers; \ 118 : using RayKernelBase::changeRayStartDirection; \ 119 : using RayKernelBase::acquireRay; \ 120 : using RayKernelBase::moveRayToBuffer