https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RayKernelBase.C
Go to the documentation of this file.
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
18{
19 auto params = RayTracingObject::validParams();
23
24 params.addParam<std::vector<std::string>>("depends_on",
25 "Other RayKernels that this RayKernel depends on");
26
27 params.registerBase("RayKernel");
28 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 params.addPrivateParam<bool>("_need_segment_reinit", false);
34
35 return params;
36}
37
39 : RayTracingObject(params),
42 RandomInterface(params, _fe_problem, _tid, false),
43 MaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS),
44 Restartable(this, "RayKernels"),
45 _current_segment_start(_trace_ray.currentIncomingPoint()),
46 _current_segment_end(_trace_ray.currentIntersectionPoint()),
47 _current_segment_length(_trace_ray.currentIntersectionDistance()),
48 _current_incoming_side(_trace_ray.currentIncomingSide()),
49 _need_segment_reinit(getParam<bool>("_need_segment_reinit"))
50{
51 // Add dependencies
52 if (isParamValid("depends_on"))
53 for (const auto & name : getParam<std::vector<std::string>>("depends_on"))
55
56 // Stateful material properties are not allowed on RayKernels
58}
59
61
62void
63RayKernelBase::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 if (!ray->shouldContinue())
70 {
71 if (ray->endSet() && ray->atEnd())
72 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 ray->getInfo());
75 else
76 mooseError("Cannot changeRayStartDirection() for a Ray that should not continue.\n\n",
77 ray->getInfo());
78 }
79
80 if (ray->trajectoryChanged())
81 mooseError("Cannot change a Ray's trajectory when its trajectory has already been changed\n\n",
82 ray->getInfo());
83
84 if (ray->endSet())
85 mooseError("Cannot change the direction of a Ray whose end point is set upon generation "
86 "(via setStartingEndPoint()).\n\n",
87 ray->getInfo());
88
89 if (_study.verifyRays() && !_current_elem->contains_point(start))
90 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 ray->getInfo());
93
94 ray->changeStartDirection(start, direction, Ray::ChangeStartDirectionKey());
95}
96
97std::shared_ptr<Ray>
98RayKernelBase::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 =
105 ray->setStart(start, _current_elem, RayTracingCommon::invalid_side);
106 ray->setStartingDirection(direction);
107
108 return ray;
109}
110
111void
112RayKernelBase::moveRayToBuffer(std::shared_ptr<Ray> & ray)
113{
114 mooseAssert(_study.currentlyPropagating(),
115 "Should not move Rays into buffer while not propagating");
116
118}
119
120void
124
125void
static InputParameters validParams()
void statefulPropertiesAllowed(bool)
static InputParameters validParams()
const std::string & name() const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
static InputParameters validParams()
virtual ~RayKernelBase()
virtual void preTrace()
Called at the beginning of the trace on this processor/thread for a Ray.
virtual void postTrace()
This method is called once a ray has reached the end of its trace.
void changeRayStartDirection(const Point &start, const Point &direction)
Changes the current Ray's start point and direction.
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a Ray into the working buffer to be traced during tracing with a meaningful error on verificati...
std::shared_ptr< Ray > acquireRay(const Point &start, const Point &direction)
Acquires a Ray to be used for generating a new Ray while tracing on the boundary.
RayKernelBase(const InputParameters &params)
static InputParameters validParams()
Base class for a MooseObject used in ray tracing.
const THREAD_ID _tid
The thread id.
static InputParameters validParams()
void dependsOn(const std::string name)
Add an object of this classes base type that this class depends on.
RayTracingStudy & _study
The RayTracingStudy associated with this object.
const std::shared_ptr< Ray > & currentRay() const
Gets the current Ray that this is working on.
const Elem *const & _current_elem
The current Elem that _current_ray is tracing through.
Key that is used for restricting access to moveRayToBufferDuringTrace() and acquireRayDuringTrace().
void moveRayToBufferDuringTrace(std::shared_ptr< Ray > &ray, const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
INTERNAL method for moving a Ray into the buffer during tracing.
std::shared_ptr< Ray > acquireRayDuringTrace(const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
INTERNAL methods for acquiring a Ray during a trace in RayKernels and RayBCs.
bool verifyRays() const
Whether or not to verify if Rays have valid information before being traced.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
Class that is used as a parameter to changeStartDirection() that allows only RayKernelBase methods to...
Definition Ray.h:76
static const unsigned short invalid_side
Identifier for an invalid side index.