https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Ray Class Reference

Basic datastructure for a ray that will traverse the mesh. More...

#include <Ray.h>

Classes

class  ChangeDirectionKey
 Class that is used as a parameter to changeDirection() that allows only RayBC methods to call changeDirection() More...
 
class  ChangePointElemSideKey
 Class that is used as a parameter to changePointElem() that allows only PeriodicRayBC methods to call changeStartDirection() More...
 
class  ChangeStartDirectionKey
 Class that is used as a parameter to changeStartDirection() that allows only RayKernelBase methods to call changeStartDirection() More...
 
class  ConstructRayKey
 Class that is used as a parameter to the public constructors/reset methods. More...
 

Public Member Functions

 Ray (RayTracingStudy *study, const RayID id, const std::size_t data_size, const std::size_t aux_data_size, const bool reset, const ConstructRayKey &)
 Ray constructor for internal use only.
 
void reset (RayTracingStudy *study, const RayID id, const std::size_t data_size, const std::size_t aux_data_size, const bool reset, const ConstructRayKey &)
 Resets a Ray for internal use only.
 
 Ray (const Ray *const other, const ConstructRayKey &)
 Copy constructor for internal use only.
 
void reset (const Ray *const other, const ConstructRayKey &)
 Resets a Ray from another Ray for internal use only.
 
Rayoperator= (const Ray &)=delete
 Deleted copy operator.
 
 Ray ()=delete
 Deleted default constructor.
 
 Ray (const Ray &other)=delete
 Deleted copy constructor.
 
bool operator== (const Ray &other) const
 Equality operator.
 
bool operator!= (const Ray &other) const
 Non-equal operator.
 
RayID id () const
 Gets the Ray's ID.
 
bool invalidID () const
 Whether or not the Ray's ID is invalid.
 
const Point & currentPoint () const
 Gets the point that the Ray is currently at.
 
bool invalidCurrentPoint () const
 Whether or not the point that the Ray is currently at is valid.
 
void changeDirection (const Point &direction, const ChangeDirectionKey)
 This method is for internal use only.
 
void changeStartDirection (const Point &start, const Point &direction, const ChangeStartDirectionKey)
 This method is for internal use only.
 
void changePointElemSide (const Point &point, const Elem &elem, const unsigned int side, const ChangePointElemSideKey)
 This method is for internal use only.
 
const Point & direction () const
 Gets the Ray's direction.
 
bool invalidDirection () const
 Whether or not the Ray's direction is set to invalid.
 
std::vector< RayData > & data ()
 Gets a writeable reference to the Ray's data.
 
const std::vector< RayData > & data () const
 Gets a read only reference to the Ray's data.
 
RayDatadata (const std::size_t i)
 Gets a writeable reference to the Ray's data at an index.
 
const RayDatadata (const std::size_t i) const
 Gets a read only reference to the Ray's data at an index.
 
std::vector< RayData > & auxData ()
 Gets a writeable reference to the Ray's auxilary data.
 
const std::vector< RayData > & auxData () const
 Gets a read only reference to the Ray's auxilary data.
 
RayDataauxData (const std::size_t i)
 Gets a writeable reference to a component of the Ray's auxilary data.
 
const RayDataauxData (const std::size_t i) const
 Gets a read only reference to a component of the Ray's auxilary data.
 
void setStart (const Point &starting_point, const Elem *starting_elem=nullptr, const unsigned short starting_incoming_side=RayTracingCommon::invalid_side)
 Sets the information pretaining to the start point for the Ray.
 
void setStartingDirection (const Point &starting_direction)
 Sets the starting direction to starting_direction for a Ray.
 
void setStartingEndPoint (const Point &starting_end_point)
 Sets the starting end point to starting_point for a Ray.
 
void setStartingMaxDistance (const Real starting_max_distance)
 Sets the maximum distance this Ray should travel to starting_max_distance.
 
void setStationary ()
 Sets the Ray to be stationary (max distance = 0).
 
void invalidateStartingElem ()
 Invalidates a Ray's starting element.
 
void invalidateStartingIncomingSide ()
 Invalidates a Ray's starting incoming side.
 
void clearStartingInfo ()
 Clears the starting information set on the Ray:
 
void resetCounters ()
 Clears the internal counters on the Ray so that the Ray can be traced again.
 
const Elem * currentElem () const
 Gets the current element that the Ray is in.
 
unsigned short currentIncomingSide () const
 Get a Ray's current incoming side.
 
bool invalidCurrentIncomingSide () const
 Whether or not the Ray's current incoming side is invalid.
 
bool endSet () const
 Whether or not the user has set an end point for this Ray.
 
bool atEnd () const
 Whether or not the Ray is at the user-defined end point.
 
Point endPoint () const
 Gets the user-set end point for the Ray, if set.
 
unsigned int processorCrossings () const
 Gets the number of times this Ray has crossed a processor.
 
unsigned int intersections () const
 Gets the number of intersections this Ray has done.
 
Real distance () const
 Gets the distance this Ray has traveled.
 
Real maxDistance () const
 Gets the max distance this Ray is allowed to travel.
 
bool maxDistanceSet () const
 Whether or not the distance has been set via setStartingMaxDistance()
 
bool stationary () const
 
bool shouldContinue () const
 Whether or not this Ray should continue.
 
void setShouldContinue (const bool should_continue)
 Sets whether or not this Ray should continue.
 
bool trajectoryChanged () const
 Whether or not this Ray has had its trajectory changed.
 
unsigned int trajectoryChanges () const
 Gets the number of trajectory changes this Ray has had.
 
std::string getInfo () const
 Helper function for getting information about the Ray.
 
bool hasTraced () const
 Whether or not a Ray has begun tracing.
 
const RayTracingStudystudy () const
 Get the RayTracingStudy associated with this Ray.
 

Static Public Attributes

static const RayDataIndex INVALID_RAY_DATA_INDEX = static_cast<RayDataIndex>(-1)
 Invalid index into a Ray's data.
 
static const RayID INVALID_RAY_ID = static_cast<RayID>(-1)
 Invalid Ray ID.
 

Private Member Functions

void changeID (const RayID id)
 Changes the Ray's ID.
 
void invalidateCurrentElem ()
 Invalidates the Ray's current element.
 
void setCurrentPoint (const Point &current_point)
 Sets the Ray's current point.
 
void invalidateCurrentPoint ()
 Invalidates the Ray's current point.
 
void setDirection (const Point &direction)
 Sets the Ray's direction.
 
void invalidateDirection ()
 Invalidates the Ray's current direction.
 
void setCurrentElem (const Elem *current_elem)
 Change a Ray's current elem.
 
void setCurrentIncomingSide (const unsigned short current_incoming_side)
 Change a Ray's incoming side.
 
void invalidateCurrentIncomingSide ()
 Invalidates the Ray's current incoming side.
 
void setTrajectoryChanged (const bool trajectory_changed)
 Set whether or not this Ray has had its trajectory changed.
 
void addProcessorCrossing ()
 Increment the Ray's processor crossing counter.
 
void addIntersection ()
 Increment the Ray's intersection counter.
 
void addTrajectoryChange ()
 Increment the Ray's trajectory change counter.
 
void addDistance (const Real add_distance)
 Adds to the distance this Ray has traveled.
 
void changeMaxDistance (const Real max_distance)
 Changes the Ray's max distance to be traveled.
 
void invalidateMaxDistance ()
 Invalidates the Ray's max distance.
 
void errorIfTracing (const std::string &reason) const
 Produces a useful error if a Ray has started tracing.
 
void errorWhenInitializing (const std::string &reason) const
 Produces a useful error for use when initializing a Ray.
 
void resetCountersInternal ()
 Reset all of the internal counters.
 
bool equalityHelper (const Ray &other, const bool equal) const
 Helper for the equality operators.
 
void clearStartingInfoInternal ()
 Clears the starting information.
 

Private Attributes

RayID _id
 A unique ID for this Ray.
 
Point _current_point
 Current point of the Ray.
 
Point _direction
 Direction of the Ray.
 
const Elem * _current_elem
 Current element that the Ray is in.
 
unsigned short _current_incoming_side
 The side of _current_elem that the Ray is incoming on (if any).
 
bool _trajectory_changed
 Whether or not this Ray had its trajectory changed (not sent in parallel)
 
bool _end_set
 Whether or not the user has set an end point for this Ray (via limiting its distance with setStartingEndPoint())
 
bool _should_continue
 Wether or not the Ray should continue to be traced (not sent in parallel)
 
unsigned int _processor_crossings
 Number of times this Ray has been communicated.
 
unsigned int _intersections
 Number of intersections done for this Ray.
 
unsigned int _trajectory_changes
 Number of times this Ray has had its trajectory changed.
 
Real _distance
 Total distance this Ray has traveled.
 
Real _max_distance
 Maximum distance the Ray is allowed to travel.
 
std::vector< RayData_data
 The data that is carried with the Ray This is mutable so that we can resize it if needed within const accessors.
 
std::vector< RayData_aux_data
 Auxiliary data that is carried with the ray This is mutable so that we can resize it if needed within const accessors.
 
RayTracingStudy_study
 The RayTracingStudy that owns this Ray (not sent in parallel)
 

Friends

class TraceRay
 
class Parallel::Packing< std::shared_ptr< Ray > >
 
class TestRayLots
 
void dataStore (std::ostream &stream, std::shared_ptr< Ray > &ray, void *context)
 
void dataLoad (std::istream &stream, std::shared_ptr< Ray > &ray, void *context)
 

Detailed Description

Basic datastructure for a ray that will traverse the mesh.

Definition at line 57 of file Ray.h.

Constructor & Destructor Documentation

◆ Ray() [1/4]

Ray::Ray ( RayTracingStudy study,
const RayID  id,
const std::size_t  data_size,
const std::size_t  aux_data_size,
const bool  reset,
const ConstructRayKey  
)

Ray constructor for internal use only.

Even though this method is public, it in general CANNOT be used publicly. This is ONLY used internally and is protected by the ConstructRayKey. In order to construct a Ray as a user, use the RayTracingStudy::acquire{}() methods, such as RayTracingStudy::acquireRay().

Parameters
studyThe study that owns the Ray
idID for the Ray
data_sizeSize of data to initialize with zeros
aux_data_sizeSize of aux data to initialize with zeros
resetWhether or not to reset the Ray information

Definition at line 22 of file Ray.C.

28 : _id(id),
31 _current_elem(nullptr),
33 _end_set(false),
34 _max_distance(std::numeric_limits<Real>::max()),
35 _data(data_size, 0),
36 _aux_data(aux_data_size, 0),
38{
40}
std::vector< RayData > _aux_data
Auxiliary data that is carried with the ray This is mutable so that we can resize it if needed within...
Definition Ray.h:741
Real _max_distance
Maximum distance the Ray is allowed to travel.
Definition Ray.h:733
Point _direction
Direction of the Ray.
Definition Ray.h:686
std::vector< RayData > _data
The data that is carried with the Ray This is mutable so that we can resize it if needed within const...
Definition Ray.h:737
void resetCountersInternal()
Reset all of the internal counters.
Definition Ray.C:406
const Elem * _current_elem
Current element that the Ray is in.
Definition Ray.h:701
bool _end_set
Whether or not the user has set an end point for this Ray (via limiting its distance with setStarting...
Definition Ray.h:717
const RayTracingStudy & study() const
Get the RayTracingStudy associated with this Ray.
Definition Ray.h:564
RayID _id
A unique ID for this Ray.
Definition Ray.h:673
RayTracingStudy & _study
The RayTracingStudy that owns this Ray (not sent in parallel)
Definition Ray.h:744
Point _current_point
Current point of the Ray.
Definition Ray.h:683
unsigned short _current_incoming_side
The side of _current_elem that the Ray is incoming on (if any).
Definition Ray.h:711
static const unsigned short invalid_side
Identifier for an invalid side index.
static const libMesh::Point invalid_point(invalid_distance, invalid_distance, invalid_distance)
Identifier for an invalid point.

◆ Ray() [2/4]

Ray::Ray ( const Ray *const  other,
const ConstructRayKey key 
)

Copy constructor for internal use only.

Even though this method is public, it in general CANNOT be used publicly. This is ONLY used internally and is protected by the ConstructRayKey. In order to construct a Ray as a user, use the RayTracingStudy::acquire{}() methods, such as RayTracingStudy::acquireRay().

Resets the counters.

Definition at line 70 of file Ray.C.

71 : Ray(&other->_study,
72 other->_id,
73 other->_data.size(),
74 other->_aux_data.size(),
75 /* reset = */ true,
76 key)
77{
78 other->errorIfTracing("Cannot copy Ray");
79
80 if (!other->invalidCurrentPoint())
82
83 if (other->_end_set)
85 else
86 {
87 if (!other->invalidDirection())
89 if (other->maxDistanceSet())
91 }
92
93 std::copy(other->_data.begin(), other->_data.end(), _data.begin());
94 std::copy(other->_aux_data.begin(), other->_aux_data.end(), _aux_data.begin());
95}
void setStartingEndPoint(const Point &starting_end_point)
Sets the starting end point to starting_point for a Ray.
Definition Ray.C:299
void setStartingDirection(const Point &starting_direction)
Sets the starting direction to starting_direction for a Ray.
Definition Ray.C:282
bool maxDistanceSet() const
Whether or not the distance has been set via setStartingMaxDistance()
Definition Ray.h:523
Ray()=delete
Deleted default constructor.
void errorIfTracing(const std::string &reason) const
Produces a useful error if a Ray has started tracing.
Definition Ray.C:385
bool invalidDirection() const
Whether or not the Ray's direction is set to invalid.
Definition Ray.h:283
Point endPoint() const
Gets the user-set end point for the Ray, if set.
Definition Ray.C:186
void setStart(const Point &starting_point, const Elem *starting_elem=nullptr, const unsigned short starting_incoming_side=RayTracingCommon::invalid_side)
Sets the information pretaining to the start point for the Ray.
Definition Ray.C:233
bool invalidCurrentPoint() const
Whether or not the point that the Ray is currently at is valid.
Definition Ray.h:237

◆ Ray() [3/4]

Ray::Ray ( )
delete

Deleted default constructor.

All Ray construction is handled internally within the RayTracingStudy via the RayTracingStudy::acquire{}() methods.

◆ Ray() [4/4]

Ray::Ray ( const Ray other)
delete

Deleted copy constructor.

All Ray construction is handled internally within the RayTracingStudy via the RayTracingStudy::acquire{}() methods.

Member Function Documentation

◆ addDistance()

void Ray::addDistance ( const Real  add_distance)
inlineprivate

Adds to the distance this Ray has traveled.

Definition at line 638 of file Ray.h.

638{ _distance += add_distance; }
Real _distance
Total distance this Ray has traveled.
Definition Ray.h:731

◆ addIntersection()

void Ray::addIntersection ( )
inlineprivate

Increment the Ray's intersection counter.

Definition at line 628 of file Ray.h.

628{ ++_intersections; }
unsigned int _intersections
Number of intersections done for this Ray.
Definition Ray.h:725

◆ addProcessorCrossing()

void Ray::addProcessorCrossing ( )
inlineprivate

Increment the Ray's processor crossing counter.

Definition at line 623 of file Ray.h.

unsigned int _processor_crossings
Number of times this Ray has been communicated.
Definition Ray.h:722

◆ addTrajectoryChange()

void Ray::addTrajectoryChange ( )
inlineprivate

Increment the Ray's trajectory change counter.

Definition at line 633 of file Ray.h.

unsigned int _trajectory_changes
Number of times this Ray has had its trajectory changed.
Definition Ray.h:728

◆ atEnd()

bool Ray::atEnd ( ) const

Whether or not the Ray is at the user-defined end point.

This is only valid when the user set the trajectory of the Ray with setStartingEndPoint(), which internally set its maximum distance to the straight-line distance between start and end and set endSet() == true.

Definition at line 176 of file Ray.C.

177{
178 if (!_end_set)
179 mooseError("Cannot use Ray::atEnd() for a Ray that does not have an end set\n\n", getInfo());
180 mooseAssert(_distance <= _max_distance + TOLERANCE * TOLERANCE, "Distance past max distance");
181
182 return MooseUtils::absoluteFuzzyEqual(_distance, _max_distance);
183}
void mooseError(Args &&... args)
std::string getInfo() const
Helper function for getting information about the Ray.
Definition Ray.C:483
static constexpr Real TOLERANCE

Referenced by getInfo().

◆ auxData() [1/4]

std::vector< RayData > & Ray::auxData ( )

Gets a writeable reference to the Ray's auxilary data.

If the aux data is not sized to the size as required by the study, this will resize the aux data.

Definition at line 451 of file Ray.C.

452{
453 mooseAssert(_aux_data.size() == 0 || _aux_data.size() == _study.rayAuxDataSize(),
454 "Ray data size is not zero or the size required by study");
456 return _aux_data;
457}
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.

Referenced by auxData(), auxData(), TestRayDataStudy::auxDataValue(), TestRayDataStudy::dataValue(), getInfo(), and TestRayDataStudy::onCompleteRay().

◆ auxData() [2/4]

const std::vector< RayData > & Ray::auxData ( ) const

Gets a read only reference to the Ray's auxilary data.

If the aux data is not sized to the size as required by the study, this will resize the aux data.

Definition at line 460 of file Ray.C.

461{
462 mooseAssert(_aux_data.size() == 0 || _aux_data.size() == _study.rayAuxDataSize(),
463 "Ray data size is not zero or the size required by study");
465 return _aux_data;
466}

◆ auxData() [3/4]

RayData & Ray::auxData ( const std::size_t  i)

Gets a writeable reference to a component of the Ray's auxilary data.

If the aux data is not sized to the size as required by the study, this will resize the aux data.

Definition at line 469 of file Ray.C.

470{
471 mooseAssert(_study.rayAuxDataSize() > i, "Accessing Ray data out of range");
472 return auxData()[i];
473}
std::vector< RayData > & auxData()
Gets a writeable reference to the Ray's auxilary data.
Definition Ray.C:451

◆ auxData() [4/4]

const RayData & Ray::auxData ( const std::size_t  i) const

Gets a read only reference to a component of the Ray's auxilary data.

If the aux data is not sized to the size as required by the study, this will resize the aux data.

Definition at line 476 of file Ray.C.

477{
478 mooseAssert(_study.rayAuxDataSize() > i, "Accessing Ray data out of range");
479 return auxData()[i];
480}

◆ changeDirection()

void Ray::changeDirection ( const Point direction,
const ChangeDirectionKey   
)

This method is for internal use only.

It is intended to be called only by RayBoundaryConditionBase::changeRayDirection().

If you wish to change a Ray's direction mid-trace in a RayBC, see RayBoundaryConditionBase::changeRayDirection() instead.

ChangeDirectionKey is constructable only by RayBC objects on purpose to limit usage of this method.

Definition at line 196 of file Ray.C.

197{
199 mooseError("Cannot set zero vector direction for a Ray\n\n", getInfo());
200
202 _trajectory_changed = true;
203}
bool _trajectory_changed
Whether or not this Ray had its trajectory changed (not sent in parallel)
Definition Ray.h:714
const Point & direction() const
Gets the Ray's direction.
Definition Ray.h:279
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
TypeVector< Real > unit() const

◆ changeID()

void Ray::changeID ( const RayID  id)
inlineprivate

Changes the Ray's ID.

Definition at line 570 of file Ray.h.

570{ _id = id; }
RayID id() const
Gets the Ray's ID.
Definition Ray.h:219

◆ changeMaxDistance()

void Ray::changeMaxDistance ( const Real  max_distance)
inlineprivate

Changes the Ray's max distance to be traveled.

Definition at line 642 of file Ray.h.

642{ _max_distance = max_distance; }

◆ changePointElemSide()

void Ray::changePointElemSide ( const Point point,
const Elem elem,
const unsigned int  side,
const ChangePointElemSideKey   
)

This method is for internal use only.

It is intended to be called only by PeriodicRayBC::onBoundary().

ChangePointElemSideKey is constructable only by PeriodicRayBC objects on purpose to limit usage of this method.

Definition at line 219 of file Ray.C.

223{
224 mooseAssert(!_trajectory_changed, "Should not have already changed");
225
226 _current_point = point;
227 _current_elem = &elem;
229 _trajectory_changed = true;
230}

◆ changeStartDirection()

void Ray::changeStartDirection ( const Point start,
const Point direction,
const ChangeStartDirectionKey   
)

This method is for internal use only.

It is intended to be called only by RayKernelBase::changeRay().

If you wish to change a Ray's direction mid-trace in a RayKernel, see RayKernelBase::changeRay() instead.

ChangeStartDirectionKey is constructable only by RayKernelBase objects on purpose to limit usage of this method.

Definition at line 206 of file Ray.C.

209{
211 mooseError("Cannot set zero vector direction for a Ray\n\n", getInfo());
212
213 _current_point = start;
215 _trajectory_changed = true;
216}

◆ clearStartingInfo()

void Ray::clearStartingInfo ( )

Clears the starting information set on the Ray:

  • Starting point
  • Starting element
  • Starting incoming side
  • Starting direction
  • Starting maximum distance

This can only be called before a Ray has begun tracing.

Definition at line 367 of file Ray.C.

368{
369 errorIfTracing("Cannot use Ray::clearStartingInfo()");
371}
void clearStartingInfoInternal()
Clears the starting information.
Definition Ray.C:374

◆ clearStartingInfoInternal()

void Ray::clearStartingInfoInternal ( )
private

Clears the starting information.

Definition at line 374 of file Ray.C.

375{
381 _end_set = false;
382}
void invalidateMaxDistance()
Invalidates the Ray's max distance.
Definition Ray.h:646
void invalidateCurrentIncomingSide()
Invalidates the Ray's current incoming side.
Definition Ray.h:610
void invalidateDirection()
Invalidates the Ray's current direction.
Definition Ray.h:593
void invalidateCurrentElem()
Invalidates the Ray's current element.
Definition Ray.h:575
void invalidateCurrentPoint()
Invalidates the Ray's current point.
Definition Ray.h:584

Referenced by clearStartingInfo(), and reset().

◆ currentElem()

const Elem * Ray::currentElem ( ) const
inline

Gets the current element that the Ray is in.

Before tracing, this is the starting element for the Ray.

During tracing:

  • It is valid within RayKernels, because a Ray can only operate on a single element per segment.
  • When used on boundaries (RayBCs), it is the element that the Ray actually traced through. When on a boundary, a RayBC may be applied to multiple elements when hitting a vertex or edge. Therefore, this will be only one of said elements.

Definition at line 449 of file Ray.h.

449{ return _current_elem; }

Referenced by getInfo().

◆ currentIncomingSide()

unsigned short Ray::currentIncomingSide ( ) const
inline

Get a Ray's current incoming side.

Before tracing, this is the starting incoming side (if any).

During and after tracing, this is ONLY guaranteed to be valid while executing RayKernels!

Definition at line 459 of file Ray.h.

459{ return _current_incoming_side; }

Referenced by getInfo().

◆ currentPoint()

const Point & Ray::currentPoint ( ) const
inline

Gets the point that the Ray is currently at.

Before a Ray is traced, this is the starting point of the Ray. While a Ray is being traced, this is the furthest point that the Ray has travelled. During RayKernel execution, this is the end of the segment. After a Ray has been traced, this is the point where the Ray was killed.

Definition at line 233 of file Ray.h.

233{ return _current_point; }

Referenced by getInfo(), and TestPICRayStudy::maxDistance().

◆ data() [1/4]

std::vector< RayData > & Ray::data ( )

Gets a writeable reference to the Ray's data.

If the data is not sized to the size as required by the study, this will resize the data.

Definition at line 417 of file Ray.C.

418{
419 mooseAssert(_data.size() == 0 || _data.size() == _study.rayDataSize(),
420 "Ray data size of " + std::to_string(_data.size()) +
421 " is not zero or the size required by the study of " +
422 std::to_string(_study.rayDataSize()));
423 _data.resize(_study.rayDataSize());
424 return _data;
425}
std::size_t rayDataSize() const
The registered size of values in the Ray data.

Referenced by data(), data(), getInfo(), and TestRayDataStudy::onCompleteRay().

◆ data() [2/4]

const std::vector< RayData > & Ray::data ( ) const

Gets a read only reference to the Ray's data.

If the data is not sized to the size as required by the study, this will resize the data.

Definition at line 428 of file Ray.C.

429{
430 mooseAssert(_data.size() == 0 || _data.size() == _study.rayDataSize(),
431 "Ray data size is not zero or the size required by study");
432 _data.resize(_study.rayDataSize());
433 return _data;
434}

◆ data() [3/4]

RayData & Ray::data ( const std::size_t  i)

Gets a writeable reference to the Ray's data at an index.

If the data is not sized to the size as required by the study, this will resize the data.

Definition at line 437 of file Ray.C.

438{
439 mooseAssert(_study.rayDataSize() > i, "Accessing Ray data out of range");
440 return data()[i];
441}
std::vector< RayData > & data()
Gets a writeable reference to the Ray's data.
Definition Ray.C:417

◆ data() [4/4]

const RayData & Ray::data ( const std::size_t  i) const

Gets a read only reference to the Ray's data at an index.

If the data is not sized to the size as required by the study, this will resize the data.

Definition at line 444 of file Ray.C.

445{
446 mooseAssert(_study.rayDataSize() > i, "Accessing Ray data out of range");
447 return data()[i];
448}

◆ direction()

const Point & Ray::direction ( ) const
inline

Gets the Ray's direction.

Definition at line 279 of file Ray.h.

279{ return _direction; }

Referenced by changeDirection(), changeStartDirection(), getInfo(), and setDirection().

◆ distance()

Real Ray::distance ( ) const
inline

Gets the distance this Ray has traveled.

Definition at line 512 of file Ray.h.

512{ return _distance; }

Referenced by TestRayDataStudy::dataValue(), and getInfo().

◆ endPoint()

Point Ray::endPoint ( ) const

Gets the user-set end point for the Ray, if set.

Internally, we do not keep track of the end point. Instead, we set a maximum straight-line distance the Ray can travel until it hits its endpoint. With the current point, the distance, the maximum distance, and the direction, we can infer the user-set end point.

Definition at line 186 of file Ray.C.

187{
188 if (!_end_set)
189 mooseError("Cannot use Ray::endPoint() for a Ray that does not have an end set\n\n", getInfo());
190 mooseAssert(_distance <= _max_distance + TOLERANCE * TOLERANCE, "Distance past max distance");
191
193}

Referenced by getInfo(), Ray(), and reset().

◆ endSet()

bool Ray::endSet ( ) const
inline

Whether or not the user has set an end point for this Ray.

This is done by limiting the distance of the Ray in its set direction.

Definition at line 478 of file Ray.h.

478{ return _end_set; }

Referenced by getInfo().

◆ equalityHelper()

bool Ray::equalityHelper ( const Ray other,
const bool  equal 
) const
private

Helper for the equality operators.

Definition at line 126 of file Ray.C.

127{
128 if (this == &other)
129 return equal;
130
131 if (_id != other._id)
132 return !equal;
133 if (invalidCurrentPoint() != other.invalidCurrentPoint() ||
135 return !equal;
136 if (invalidDirection() != other.invalidDirection() ||
138 return !equal;
139 if (_current_elem != other._current_elem)
140 return !equal;
142 return !equal;
144 return !equal;
145 if (_end_set != other._end_set)
146 return !equal;
148 return !equal;
150 return !equal;
151 if (_intersections != other._intersections)
152 return !equal;
154 return !equal;
155 if (!MooseUtils::absoluteFuzzyEqual(_distance, other._distance))
156 return !equal;
157 if (!MooseUtils::absoluteFuzzyEqual(_max_distance, other._max_distance))
158 return !equal;
159 if (_data.size() != other._data.size())
160 return !equal;
161 for (std::size_t i = 0; i < _data.size(); ++i)
162 if (!MooseUtils::absoluteFuzzyEqual(_data[i], other._data[i]))
163 return !equal;
164 if (_aux_data.size() != other._aux_data.size())
165 return !equal;
166 for (std::size_t i = 0; i < _aux_data.size(); ++i)
167 if (!MooseUtils::absoluteFuzzyEqual(_aux_data[i], other._aux_data[i]))
168 return !equal;
169 if (&_study != &other._study)
170 return !equal;
171
172 return equal;
173}
bool _should_continue
Wether or not the Ray should continue to be traced (not sent in parallel)
Definition Ray.h:719

Referenced by operator!=(), and operator==().

◆ errorIfTracing()

void Ray::errorIfTracing ( const std::string &  reason) const
private

Produces a useful error if a Ray has started tracing.

Definition at line 385 of file Ray.C.

386{
387 if (hasTraced())
388 mooseError(reason, " after it has started tracing\n\n", getInfo());
389}
bool hasTraced() const
Whether or not a Ray has begun tracing.
Definition Ray.h:556

Referenced by clearStartingInfo(), invalidateStartingElem(), invalidateStartingIncomingSide(), Ray(), reset(), setStart(), setStartingDirection(), setStartingEndPoint(), setStartingMaxDistance(), and setStationary().

◆ errorWhenInitializing()

void Ray::errorWhenInitializing ( const std::string &  reason) const
private

Produces a useful error for use when initializing a Ray.

Definition at line 392 of file Ray.C.

393{
394 mooseError("While initializing starting information for a Ray:\n\n", reason, "\n\n", getInfo());
395}

Referenced by setStart(), setStartingDirection(), setStartingEndPoint(), setStartingMaxDistance(), and setStationary().

◆ getInfo()

std::string Ray::getInfo ( ) const

Helper function for getting information about the Ray.

Definition at line 483 of file Ray.C.

484{
485 std::ostringstream oss;
486
487 oss << "Ray information with " << _study.type() << " '" << _study.name() << "' on pid "
488 << _study.comm().rank() << "\n";
489 oss << " this = " << this << "\n";
490 oss << " id() = " << id() << "\n";
492 oss << " _study.registeredRayName(id()) = " << _study.registeredRayName(id()) << "\n";
493 oss << " currentPoint() = ";
495 oss << "invalid point\n";
496 else
497 oss << currentPoint() << "\n";
498 oss << " direction() = ";
499 if (invalidDirection())
500 oss << "invalid point\n";
501 else
502 oss << direction() << "\n";
503 oss << " currentIncomingSide() = ";
505 oss << "invalid side\n";
506 else
507 oss << currentIncomingSide() << "\n";
508 oss << " endSet() = " << (endSet() ? "true" : "false") << "\n";
509 if (endSet())
510 {
511 oss << " endPoint() = " << endPoint() << "\n";
512 oss << " atEnd() = " << (atEnd() ? "true" : "false") << "\n";
513 }
514 oss << " distance() = " << distance() << "\n";
515 oss << " maxDistance() = " << maxDistance() << "\n";
516 if (currentElem())
517 {
518 oss << " currentElem()->id() = " << currentElem()->id() << "\n";
519 oss << " currentElem()->processor_id() = " << currentElem()->processor_id() << "\n";
520 }
521 else
522 oss << " currentElem()->id() = invalid\n";
523 oss << " processorCrossings() = " << processorCrossings() << "\n";
524 oss << " intersections() = " << intersections() << "\n";
525 oss << " trajectoryChanges() = " << trajectoryChanges() << "\n";
526 oss << " shouldContinue() = " << (shouldContinue() ? "true" : "false") << "\n";
527 oss << " trajectoryChanged() = " << (trajectoryChanged() ? "true" : "false") << "\n";
528 oss << " data() = ";
529 for (std::size_t i = 0; i < data().size(); ++i)
530 oss << "\n '" << _study.getRayDataName(i) << "' = " << data(i);
531 oss << "\n";
532 oss << " auxData() = ";
533 for (std::size_t i = 0; i < auxData().size(); ++i)
534 oss << "\n '" << _study.getRayAuxDataName(i) << "' = " << auxData(i);
535 oss << "\n";
536
537 return oss.str();
538}
const std::string & type() const
const std::string & name() const
const std::string & getRayAuxDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray aux data.
bool useRayRegistration() const
Whether or not ray registration is being used.
const std::string & registeredRayName(const RayID ray_id) const
Gets the name of a registered ray.
const std::string & getRayDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray data.
unsigned short currentIncomingSide() const
Get a Ray's current incoming side.
Definition Ray.h:459
bool endSet() const
Whether or not the user has set an end point for this Ray.
Definition Ray.h:478
unsigned int trajectoryChanges() const
Gets the number of trajectory changes this Ray has had.
Definition Ray.h:546
bool invalidCurrentIncomingSide() const
Whether or not the Ray's current incoming side is invalid.
Definition Ray.h:468
Real distance() const
Gets the distance this Ray has traveled.
Definition Ray.h:512
Real maxDistance() const
Gets the max distance this Ray is allowed to travel.
Definition Ray.h:519
unsigned int processorCrossings() const
Gets the number of times this Ray has crossed a processor.
Definition Ray.h:502
bool trajectoryChanged() const
Whether or not this Ray has had its trajectory changed.
Definition Ray.h:542
unsigned int intersections() const
Gets the number of intersections this Ray has done.
Definition Ray.h:507
const Elem * currentElem() const
Gets the current element that the Ray is in.
Definition Ray.h:449
const Point & currentPoint() const
Gets the point that the Ray is currently at.
Definition Ray.h:233
bool invalidID() const
Whether or not the Ray's ID is invalid.
Definition Ray.h:223
bool atEnd() const
Whether or not the Ray is at the user-defined end point.
Definition Ray.C:176
bool shouldContinue() const
Whether or not this Ray should continue.
Definition Ray.h:533
processor_id_type rank() const
processor_id_type processor_id() const
dof_id_type id() const
const Parallel::Communicator & comm() const

Referenced by atEnd(), changeDirection(), changeStartDirection(), endPoint(), errorIfTracing(), errorWhenInitializing(), resetCounters(), and RepeatableRayStudyBase::verifyReplicatedRays().

◆ hasTraced()

bool Ray::hasTraced ( ) const
inline

Whether or not a Ray has begun tracing.

Definition at line 556 of file Ray.h.

557 {
558 return (bool)_distance || (bool)_processor_crossings || (bool)_intersections;
559 }

Referenced by errorIfTracing().

◆ id()

RayID Ray::id ( ) const
inline

Gets the Ray's ID.

Definition at line 219 of file Ray.h.

219{ return _id; }

Referenced by changeID(), and getInfo().

◆ intersections()

unsigned int Ray::intersections ( ) const
inline

Gets the number of intersections this Ray has done.

Definition at line 507 of file Ray.h.

507{ return _intersections; }

Referenced by getInfo().

◆ invalidateCurrentElem()

void Ray::invalidateCurrentElem ( )
inlineprivate

Invalidates the Ray's current element.

Definition at line 575 of file Ray.h.

575{ _current_elem = nullptr; }

Referenced by clearStartingInfoInternal(), and invalidateStartingElem().

◆ invalidateCurrentIncomingSide()

void Ray::invalidateCurrentIncomingSide ( )
inlineprivate

Invalidates the Ray's current incoming side.

Definition at line 610 of file Ray.h.

Referenced by clearStartingInfoInternal(), and invalidateStartingIncomingSide().

◆ invalidateCurrentPoint()

void Ray::invalidateCurrentPoint ( )
inlineprivate

Invalidates the Ray's current point.

Definition at line 584 of file Ray.h.

Referenced by clearStartingInfoInternal().

◆ invalidateDirection()

void Ray::invalidateDirection ( )
inlineprivate

Invalidates the Ray's current direction.

Definition at line 593 of file Ray.h.

Referenced by clearStartingInfoInternal().

◆ invalidateMaxDistance()

void Ray::invalidateMaxDistance ( )
inlineprivate

Invalidates the Ray's max distance.

Definition at line 646 of file Ray.h.

646{ _max_distance = std::numeric_limits<Real>::max(); }

Referenced by clearStartingInfoInternal().

◆ invalidateStartingElem()

void Ray::invalidateStartingElem ( )

Invalidates a Ray's starting element.

This is useful after the mesh has changed due to adaptivity, in which the starting element may no longer be valid.

This can only be called before a Ray has begun tracing.

Definition at line 353 of file Ray.C.

354{
355 errorIfTracing("Cannot use Ray::invalidateStartingElem()");
357}

◆ invalidateStartingIncomingSide()

void Ray::invalidateStartingIncomingSide ( )

Invalidates a Ray's starting incoming side.

This is useful after the mesh has changed due to adaptivity, in which the incoming side may no longer be valid.

This can only be called before a Ray has begun tracing.

Definition at line 360 of file Ray.C.

361{
362 errorIfTracing("Cannot use Ray::invalidateStartingIncomingSide()");
364}

◆ invalidCurrentIncomingSide()

bool Ray::invalidCurrentIncomingSide ( ) const
inline

Whether or not the Ray's current incoming side is invalid.

Before tracing, this is the starting incoming side (if any).

During and after tracing, this is ONLY guaranteed to be valid while executing RayKernels!

Definition at line 468 of file Ray.h.

Referenced by getInfo(), and setStart().

◆ invalidCurrentPoint()

bool Ray::invalidCurrentPoint ( ) const
inline

Whether or not the point that the Ray is currently at is valid.

Definition at line 237 of file Ray.h.

Referenced by equalityHelper(), getInfo(), Ray(), reset(), setStart(), setStartingDirection(), setStartingEndPoint(), setStartingMaxDistance(), and setStationary().

◆ invalidDirection()

bool Ray::invalidDirection ( ) const
inline

Whether or not the Ray's direction is set to invalid.

Definition at line 283 of file Ray.h.

Referenced by equalityHelper(), getInfo(), Ray(), reset(), setStartingDirection(), setStartingEndPoint(), and setStationary().

◆ invalidID()

bool Ray::invalidID ( ) const
inline

Whether or not the Ray's ID is invalid.

Definition at line 223 of file Ray.h.

223{ return _id == INVALID_RAY_ID; }
static const RayID INVALID_RAY_ID
Invalid Ray ID.
Definition Ray.h:214

Referenced by getInfo().

◆ maxDistance()

Real Ray::maxDistance ( ) const
inline

Gets the max distance this Ray is allowed to travel.

This may be set internally to || end - start || in the case that the user initialized the Ray with setStartingEndPoint().

Definition at line 519 of file Ray.h.

519{ return _max_distance; }

Referenced by getInfo().

◆ maxDistanceSet()

bool Ray::maxDistanceSet ( ) const
inline

Whether or not the distance has been set via setStartingMaxDistance()

Definition at line 523 of file Ray.h.

523{ return _max_distance != std::numeric_limits<Real>::max(); }

Referenced by Ray(), reset(), and setStartingEndPoint().

◆ operator!=()

bool Ray::operator!= ( const Ray other) const
inline

Non-equal operator.

This will perform "fuzzy" equals checks on the points and data.

Definition at line 209 of file Ray.h.

209{ return equalityHelper(other, false); }
bool equalityHelper(const Ray &other, const bool equal) const
Helper for the equality operators.
Definition Ray.C:126

◆ operator=()

Ray & Ray::operator= ( const Ray )
delete

Deleted copy operator.

General Ray modification is handled internally within the RayTracingStudy via the RayTracingStudy::acquire{}() methods.

◆ operator==()

bool Ray::operator== ( const Ray other) const
inline

Equality operator.

This will perform "fuzzy" equals checks on the points and data.

Definition at line 203 of file Ray.h.

203{ return equalityHelper(other, true); }

◆ processorCrossings()

unsigned int Ray::processorCrossings ( ) const
inline

Gets the number of times this Ray has crossed a processor.

Definition at line 502 of file Ray.h.

502{ return _processor_crossings; }

Referenced by getInfo().

◆ reset() [1/2]

void Ray::reset ( const Ray *const  other,
const ConstructRayKey  
)

Resets a Ray from another Ray for internal use only.

Used by the SharedPool to reset a Ray from another.

Even though this method is public, it in general CANNOT be used publicly. This is ONLY used internally and is protected by the ConstructRayKey. In order to construct a Ray as a user, use the RayTracingStudy::acquire{}() methods, such as RayTracingStudy::acquireRay().

Resets the counters.

Definition at line 98 of file Ray.C.

99{
100 other->errorIfTracing("Cannot copy Ray");
101 mooseAssert(&other->_study == &_study, "Cannot copy Ray from different study");
102
105
106 _id = other->_id;
107
108 if (!other->invalidCurrentPoint())
110
111 if (other->_end_set)
113 else
114 {
115 if (!other->invalidDirection())
117 if (other->maxDistanceSet())
119 }
120
121 _data = other->_data;
122 _aux_data = other->_aux_data;
123}

◆ reset() [2/2]

void Ray::reset ( RayTracingStudy study,
const RayID  id,
const std::size_t  data_size,
const std::size_t  aux_data_size,
const bool  reset,
const ConstructRayKey  
)

Resets a Ray for internal use only.

Used by the SharedPool to reset a Ray with these forwarded arguments.

Even though this method is public, it in general CANNOT be used publicly. This is ONLY used internally and is protected by the ConstructRayKey. In order to construct a Ray as a user, use the RayTracingStudy::acquire{}() methods, such as RayTracingStudy::acquireRay().

Parameters
studyThe study that owns the Ray
idID for the Ray
data_sizeSize of data to initialize with zeros
aux_data_sizeSize of aux data to initialize with zeros
resetWhether or not to reset the Ray information

◆ resetCounters()

void Ray::resetCounters ( )

Clears the internal counters on the Ray so that the Ray can be traced again.

Can only be used within generateRays().

Definition at line 398 of file Ray.C.

399{
401 mooseError("Ray::resetCounters() can only be used during generateRays()\n\n", getInfo());
403}
bool currentlyGenerating() const
Whether or not the study is generating.

◆ resetCountersInternal()

void Ray::resetCountersInternal ( )
private

Reset all of the internal counters.

Definition at line 406 of file Ray.C.

407{
409 _intersections = 0;
411 _distance = 0;
412 _trajectory_changed = false;
413 _should_continue = true;
414}

Referenced by Ray(), reset(), and resetCounters().

◆ setCurrentElem()

void Ray::setCurrentElem ( const Elem *  current_elem)
inlineprivate

Change a Ray's current elem.

Definition at line 598 of file Ray.h.

598{ _current_elem = current_elem; }

◆ setCurrentIncomingSide()

void Ray::setCurrentIncomingSide ( const unsigned short  current_incoming_side)
inlineprivate

Change a Ray's incoming side.

Definition at line 603 of file Ray.h.

604 {
605 _current_incoming_side = current_incoming_side;
606 }

◆ setCurrentPoint()

void Ray::setCurrentPoint ( const Point &  current_point)
inlineprivate

Sets the Ray's current point.

Definition at line 580 of file Ray.h.

580{ _current_point = current_point; }

◆ setDirection()

void Ray::setDirection ( const Point &  direction)
inlineprivate

Sets the Ray's direction.

Definition at line 589 of file Ray.h.

◆ setShouldContinue()

void Ray::setShouldContinue ( const bool  should_continue)
inline

Sets whether or not this Ray should continue.

Definition at line 537 of file Ray.h.

537{ _should_continue = should_continue; }

◆ setStart()

void Ray::setStart ( const Point starting_point,
const Elem starting_elem = nullptr,
const unsigned short  starting_incoming_side = RayTracingCommon::invalid_side 
)

Sets the information pretaining to the start point for the Ray.

This MUST be called before setStartingDirection(), setStartingEndPoint(), or setStartingMaxDistance(). It cannot be called after a Ray has begun tracing.

Parameters
starting_pointThe starting point
starting_elemThe starting element (if known)
starting_incoming_sideThe starting incoming side (if known and if the Ray starts on a side of starting_elem

Definition at line 233 of file Ray.C.

236{
237 mooseAssert(starting_point != RayTracingCommon::invalid_point, "Invalid point");
238 errorIfTracing("Cannot use Ray::setStart()");
240 errorWhenInitializing("Starting point was already set via Ray::setStart() and is being changed."
241 "\n\nYou may only call Ray::setStart() after it has been called once to"
242 "\nchange the starting element and starting incoming side."
243 "\n\nYou may also clear the starting info via Ray::clearStartingInfo().");
244
245 _current_point = starting_point;
246 _current_elem = starting_elem;
247 _current_incoming_side = starting_incoming_side;
248
249 if (_study.verifyRays())
250 {
251 if (!_study.looseBoundingBox().contains_point(starting_point))
252 errorWhenInitializing("Mesh does not contain starting point.");
253 if (starting_elem)
254 {
255 mooseAssert(_study.meshBase().query_elem_ptr(starting_elem->id()) == starting_elem,
256 "Element is not owned by the mesh");
257 if (!starting_elem->active())
258 errorWhenInitializing("Starting element is not active.");
259 }
260
261 bool non_planar_start = false;
262
264 {
265 if (!starting_elem)
266 errorWhenInitializing("Starting incoming side is set but starting element is not set.");
267 if (starting_elem->n_sides() < starting_incoming_side)
268 errorWhenInitializing("Starting incoming side is not valid for its starting element.");
269
270 non_planar_start = _study.sideIsNonPlanar(starting_elem, starting_incoming_side);
271 if (!non_planar_start &&
272 !starting_elem->build_side_ptr(starting_incoming_side)->contains_point(starting_point))
273 errorWhenInitializing("Starting incoming side does not contain the starting point.");
274 }
275
276 if (starting_elem && !non_planar_start && !starting_elem->contains_point(starting_point))
277 errorWhenInitializing("Starting element does not contain the starting point.");
278 }
279}
MeshBase & meshBase() const
Access to the libMesh MeshBase.
bool sideIsNonPlanar(const Elem *elem, const unsigned short s) const
Whether or not the side \s on elem elem is non-planar.
const BoundingBox & looseBoundingBox() const
Get the loose nodal bounding box for the domain.
bool verifyRays() const
Whether or not to verify if Rays have valid information before being traced.
void errorWhenInitializing(const std::string &reason) const
Produces a useful error for use when initializing a Ray.
Definition Ray.C:392
bool contains_point(const Point &) const
bool active() const
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
virtual unsigned int n_sides() const=0
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
virtual const Elem * query_elem_ptr(const dof_id_type i) const=0

Referenced by Ray(), and reset().

◆ setStartingDirection()

void Ray::setStartingDirection ( const Point starting_direction)

Sets the starting direction to starting_direction for a Ray.

This MUST be called after setStart(). It cannot be used with setStartingEndPoint(), which sets the direction internally. It cannot be called after a Ray has begun tracing.

Definition at line 282 of file Ray.C.

283{
284 errorIfTracing("Cannot use Ray::setStartingDirection()");
286 errorWhenInitializing("Cannot use Ray::setStartingDirection() before Ray::setStart().");
287 if (!invalidDirection())
289 "Cannot change a Ray's starting direction using Ray::setStartingDirection()"
290 "\nafter it has already been set."
291 "\n\nYou must first clear the starting info using Ray::clearStartingInfo().");
292 if (starting_direction.absolute_fuzzy_equals(Point(0, 0, 0)))
293 errorWhenInitializing("Starting direction in Ray::setStartingDirection() is the zero vector.");
294
295 _direction = starting_direction.unit();
296}

Referenced by Ray(), reset(), and setStartingEndPoint().

◆ setStartingEndPoint()

void Ray::setStartingEndPoint ( const Point starting_end_point)

Sets the starting end point to starting_point for a Ray.

This MUST be called after setStart(). It cannot be used with setStartingDirection(). It cannot be called after a Ray has begun tracing.

Internally, this sets the direction to be currentPoint() -> starting_direction, and sets the maximum distance to || starting_direction - currentPoint() ||.

Definition at line 299 of file Ray.C.

300{
301 errorIfTracing("Cannot use Ray::setStartingEndPoint()");
303 errorWhenInitializing("Cannot use Ray::setStartingEndPoint() before Ray::setStart().");
304 if (_current_point.absolute_fuzzy_equals(starting_end_point))
305 errorWhenInitializing("End point is equal to the start point in Ray::setStartingEndPoint().");
306 if (!invalidDirection())
307 errorWhenInitializing("Cannot use Ray::setStartingEndPoint() after Ray::setStartingDirection()."
308 "\n\nClear the starting information with Ray::clearStartingInfo().");
309 if (maxDistanceSet())
311 "Cannot use Ray::setStartingEndPoint() after Ray::setStartingMaxDistance().");
312
313 if (_study.verifyRays() && !_study.looseBoundingBox().contains_point(starting_end_point))
314 errorWhenInitializing("End point is not within the mesh for Ray::setStartingEndPoint().");
315
316 Point difference = starting_end_point;
317 difference -= _current_point;
318 setStartingMaxDistance(difference.norm());
319 setStartingDirection(difference);
320 _end_set = true;
321}
void setStartingMaxDistance(const Real starting_max_distance)
Sets the maximum distance this Ray should travel to starting_max_distance.
Definition Ray.C:324
auto norm() const

Referenced by Ray(), and reset().

◆ setStartingMaxDistance()

void Ray::setStartingMaxDistance ( const Real  starting_max_distance)

Sets the maximum distance this Ray should travel to starting_max_distance.

This MUST be called after setStart(). It cannot be used with setStartingEndPoint(). It cannot be called after a Ray has begun tracing.

If setting a Ray's trajectory with setStartingEndPoint(), the max distance is set internally to be || end - start ||.

Can only be called before a Ray has started to be traced!

Definition at line 324 of file Ray.C.

325{
326 errorIfTracing("Cannot use Ray::setStartingMaxDistance()");
328 errorWhenInitializing("Cannot use Ray::setStartingMaxDistance() before Ray::setStart().");
329 if (starting_max_distance <= 0)
330 errorWhenInitializing("Starting max distance is <= 0 in Ray::setStartingMaxDistance().");
331 if (_end_set)
333 "Cannot use Ray::setStartingMaxDistance() after Ray::setStartingEndPoint().");
334
335 _max_distance = starting_max_distance;
336}

Referenced by setStartingEndPoint().

◆ setStationary()

void Ray::setStationary ( )

Sets the Ray to be stationary (max distance = 0).

This MUST be called after setStart(). It cannot be used with setStartingEndPoint(). It cannot be called after a Ray has begun tracing.

Can only be called before a Ray has started to be traced!

Definition at line 339 of file Ray.C.

340{
341 errorIfTracing("Cannot use Ray::setStationary()");
343 errorWhenInitializing("Cannot use Ray::setStationary() before Ray::setStart()");
344 if (_end_set)
345 errorWhenInitializing("Cannot use Ray::setStationary() after Ray::setStartingEndPoint()");
346 if (!invalidDirection())
347 errorWhenInitializing("Cannot use Ray::setStationary() with Ray::setStartingDirection()");
348 _max_distance = 0;
349 mooseAssert(stationary(), "Stationary not set");
350}
bool stationary() const
Definition Ray.h:758

◆ setTrajectoryChanged()

void Ray::setTrajectoryChanged ( const bool  trajectory_changed)
inlineprivate

Set whether or not this Ray has had its trajectory changed.

Definition at line 615 of file Ray.h.

616 {
617 _trajectory_changed = trajectory_changed;
618 }

◆ shouldContinue()

bool Ray::shouldContinue ( ) const
inline

Whether or not this Ray should continue.

Definition at line 533 of file Ray.h.

533{ return _should_continue; }

Referenced by getInfo().

◆ stationary()

bool Ray::stationary ( ) const
inline
Returns
Whether or not the Ray is set to be stationary

Definition at line 758 of file Ray.h.

759{
760 const bool stationary = _max_distance == 0;
761 if (stationary)
762 mooseAssert(_intersections == 0, "Should be zero");
763 return stationary;
764}

Referenced by setStationary().

◆ study()

const RayTracingStudy & Ray::study ( ) const
inline

Get the RayTracingStudy associated with this Ray.

Definition at line 564 of file Ray.h.

564{ return _study; }

◆ trajectoryChanged()

bool Ray::trajectoryChanged ( ) const
inline

Whether or not this Ray has had its trajectory changed.

Definition at line 542 of file Ray.h.

542{ return _trajectory_changed; }

Referenced by getInfo().

◆ trajectoryChanges()

unsigned int Ray::trajectoryChanges ( ) const
inline

Gets the number of trajectory changes this Ray has had.

Definition at line 546 of file Ray.h.

546{ return _trajectory_changes; }

Referenced by getInfo().

Friends And Related Symbol Documentation

◆ dataLoad

void dataLoad ( std::istream &  stream,
std::shared_ptr< Ray > &  ray,
void *  context 
)
friend

Definition at line 738 of file Ray.C.

739{
740 mooseAssert(context, "Missing RayTracingStudy context");
741 RayTracingStudy * study = static_cast<RayTracingStudy *>(context);
742
743 RayID id;
744 loadHelper(stream, id, context);
745 ray = study->acquireRayInternal(id,
746 /* data_size = */ 0,
747 /* aux_data_size = */ 0,
748 /* reset = */ true,
750
751 loadHelper(stream, ray->_current_point, context);
752 loadHelper(stream, ray->_direction, context);
753 dof_id_type current_elem_id;
754 loadHelper(stream, current_elem_id, context);
755 ray->_current_elem = study->meshBase().query_elem_ptr(current_elem_id);
756 loadHelper(stream, ray->_current_incoming_side, context);
757 loadHelper(stream, ray->_trajectory_changed, context);
758 loadHelper(stream, ray->_end_set, context);
759 loadHelper(stream, ray->_should_continue, context);
760 loadHelper(stream, ray->_processor_crossings, context);
761 loadHelper(stream, ray->_intersections, context);
762 loadHelper(stream, ray->_trajectory_changes, context);
763 loadHelper(stream, ray->_distance, context);
764 loadHelper(stream, ray->_max_distance, context);
765 loadHelper(stream, ray->_data, context);
766 loadHelper(stream, ray->_aux_data, context);
767
768 if (ray->hasTraced())
770 "Cannot not load a Ray that has already traced during generation or propagation; "
771 "reset the Ray first");
772}
void loadHelper(std::istream &stream, P &data, void *context)
unsigned long int RayID
Type for a Ray's ID.
Definition Ray.h:44
Key that is used for restricting access to acquireRayInternal().
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
std::shared_ptr< Ray > acquireRayInternal(const RayID id, const std::size_t data_size, const std::size_t aux_data_size, const bool reset, const AcquireRayInternalKey &)
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
uint8_t dof_id_type

◆ dataStore

void dataStore ( std::ostream &  stream,
std::shared_ptr< Ray > &  ray,
void *  context 
)
friend

Definition at line 713 of file Ray.C.

714{
715 mooseAssert(ray, "Null ray");
716 mooseAssert(context, "Missing RayTracingStudy context");
717 mooseAssert(static_cast<RayTracingStudy *>(context) == &ray->study(), "Different study");
718
719 storeHelper(stream, ray->_id, context);
720 storeHelper(stream, ray->_current_point, context);
721 storeHelper(stream, ray->_direction, context);
722 auto current_elem_id = ray->currentElem() ? ray->currentElem()->id() : DofObject::invalid_id;
723 storeHelper(stream, current_elem_id, context);
724 storeHelper(stream, ray->_current_incoming_side, context);
725 storeHelper(stream, ray->_trajectory_changed, context);
726 storeHelper(stream, ray->_end_set, context);
727 storeHelper(stream, ray->_should_continue, context);
728 storeHelper(stream, ray->_processor_crossings, context);
729 storeHelper(stream, ray->_intersections, context);
730 storeHelper(stream, ray->_trajectory_changes, context);
731 storeHelper(stream, ray->_distance, context);
732 storeHelper(stream, ray->_max_distance, context);
733 storeHelper(stream, ray->_data, context);
734 storeHelper(stream, ray->_aux_data, context);
735}
void storeHelper(std::ostream &stream, P &data, void *context)
static constexpr dof_id_type invalid_id

◆ Parallel::Packing< std::shared_ptr< Ray > >

friend class Parallel::Packing< std::shared_ptr< Ray > >
friend

Definition at line 747 of file Ray.h.

◆ TestRayLots

friend class TestRayLots
friend

Definition at line 751 of file Ray.h.

◆ TraceRay

friend class TraceRay
friend

Definition at line 747 of file Ray.h.

Member Data Documentation

◆ _aux_data

std::vector<RayData> Ray::_aux_data
mutableprivate

Auxiliary data that is carried with the ray This is mutable so that we can resize it if needed within const accessors.

Definition at line 741 of file Ray.h.

Referenced by auxData(), auxData(), equalityHelper(), Ray(), and reset().

◆ _current_elem

const Elem* Ray::_current_elem
private

Current element that the Ray is in.

Before tracing, this is the starting element for the Ray.

During tracing:

  • It is valid within RayKernels, because a Ray can only operate on a single element per segment.
  • When used on boundaries (RayBCs), it is the element that the Ray actually traced through. When on a boundary, a RayBC may be applied to multiple elements when hitting a vertex or edge. Therefore, this will be only one of said elements.

Definition at line 701 of file Ray.h.

Referenced by changePointElemSide(), currentElem(), equalityHelper(), invalidateCurrentElem(), Ray(), reset(), setCurrentElem(), and setStart().

◆ _current_incoming_side

unsigned short Ray::_current_incoming_side
private

The side of _current_elem that the Ray is incoming on (if any).

Before tracing, this is the starting incoming side (if any).

During tracing, this is ONLY guaranteed to be valid during the execution of RayKernels!

Definition at line 711 of file Ray.h.

Referenced by changePointElemSide(), currentIncomingSide(), equalityHelper(), invalidateCurrentIncomingSide(), invalidCurrentIncomingSide(), Ray(), reset(), setCurrentIncomingSide(), and setStart().

◆ _current_point

Point Ray::_current_point
private

Current point of the Ray.

Before tracing, this is the starting point for the Ray. During tracing, this is the furthest ahead that a Ray has traced. For example, when on a segment in a RayKernel, this will be end of said segment. After tracing, this is where the Ray ended.

Definition at line 683 of file Ray.h.

Referenced by changePointElemSide(), changeStartDirection(), currentPoint(), endPoint(), equalityHelper(), invalidateCurrentPoint(), invalidCurrentPoint(), Ray(), reset(), setCurrentPoint(), setStart(), and setStartingEndPoint().

◆ _data

std::vector<RayData> Ray::_data
mutableprivate

The data that is carried with the Ray This is mutable so that we can resize it if needed within const accessors.

Definition at line 737 of file Ray.h.

Referenced by data(), data(), equalityHelper(), Ray(), and reset().

◆ _direction

Point Ray::_direction
private

◆ _distance

Real Ray::_distance
private

Total distance this Ray has traveled.

Definition at line 731 of file Ray.h.

Referenced by addDistance(), atEnd(), distance(), endPoint(), equalityHelper(), hasTraced(), and resetCountersInternal().

◆ _end_set

bool Ray::_end_set
private

Whether or not the user has set an end point for this Ray (via limiting its distance with setStartingEndPoint())

Definition at line 717 of file Ray.h.

Referenced by atEnd(), clearStartingInfoInternal(), endPoint(), endSet(), equalityHelper(), Ray(), reset(), setStartingEndPoint(), setStartingMaxDistance(), and setStationary().

◆ _id

RayID Ray::_id
private

A unique ID for this Ray.

Definition at line 673 of file Ray.h.

Referenced by changeID(), equalityHelper(), id(), invalidID(), and reset().

◆ _intersections

unsigned int Ray::_intersections
private

Number of intersections done for this Ray.

Definition at line 725 of file Ray.h.

Referenced by addIntersection(), equalityHelper(), hasTraced(), intersections(), and resetCountersInternal().

◆ _max_distance

Real Ray::_max_distance
private

Maximum distance the Ray is allowed to travel.

Definition at line 733 of file Ray.h.

Referenced by atEnd(), changeMaxDistance(), endPoint(), equalityHelper(), invalidateMaxDistance(), maxDistance(), maxDistanceSet(), Ray(), reset(), setStartingMaxDistance(), and setStationary().

◆ _processor_crossings

unsigned int Ray::_processor_crossings
private

Number of times this Ray has been communicated.

Definition at line 722 of file Ray.h.

Referenced by addProcessorCrossing(), equalityHelper(), hasTraced(), processorCrossings(), and resetCountersInternal().

◆ _should_continue

bool Ray::_should_continue
private

Wether or not the Ray should continue to be traced (not sent in parallel)

Definition at line 719 of file Ray.h.

Referenced by equalityHelper(), resetCountersInternal(), setShouldContinue(), and shouldContinue().

◆ _study

RayTracingStudy& Ray::_study
private

The RayTracingStudy that owns this Ray (not sent in parallel)

Definition at line 744 of file Ray.h.

Referenced by auxData(), auxData(), auxData(), auxData(), data(), data(), data(), data(), equalityHelper(), getInfo(), reset(), resetCounters(), setStart(), setStartingEndPoint(), and study().

◆ _trajectory_changed

bool Ray::_trajectory_changed
private

Whether or not this Ray had its trajectory changed (not sent in parallel)

Definition at line 714 of file Ray.h.

Referenced by changeDirection(), changePointElemSide(), changeStartDirection(), equalityHelper(), resetCountersInternal(), setTrajectoryChanged(), and trajectoryChanged().

◆ _trajectory_changes

unsigned int Ray::_trajectory_changes
private

Number of times this Ray has had its trajectory changed.

Definition at line 728 of file Ray.h.

Referenced by addTrajectoryChange(), equalityHelper(), resetCountersInternal(), and trajectoryChanges().

◆ INVALID_RAY_DATA_INDEX

const RayDataIndex Ray::INVALID_RAY_DATA_INDEX = static_cast<RayDataIndex>(-1)
static

◆ INVALID_RAY_ID

const RayID Ray::INVALID_RAY_ID = static_cast<RayID>(-1)
static

The documentation for this class was generated from the following files: