26 #include "libmesh/enum_elem_type.h" 27 #include "libmesh/elem_side_builder.h" 88 void trace(
const std::shared_ptr<Ray> & ray);
166 const std::vector<NeighborInfo> &
getVertexNeighbors(
const Elem * elem,
const Node * vertex);
173 const unsigned short vertex);
180 const std::vector<NeighborInfo> &
182 const std::pair<const Node *, const Node *> & vertices,
183 const Point & point);
190 const std::vector<NeighborInfo> &
192 const std::pair<unsigned short, unsigned short> & vertices,
193 const Point & point);
199 const std::vector<NeighborInfo> &
getPointNeighbors(
const Elem * elem,
const Point & point);
203 const std::vector<NeighborInfo> &
210 void onSegment(
const std::shared_ptr<Ray> & ray);
215 void onBoundary(
const std::shared_ptr<Ray> & ray,
const bool external);
244 std::string
failTraceMessage(
const std::string & reason,
const int line = -1);
252 void failTrace(
const std::string & reason,
const bool warning,
const int line = -1);
280 const unsigned short incoming_side,
281 Point & intersection_point,
282 unsigned short & intersected_side,
284 Real & intersection_distance,
285 const Point * normals);
302 template <
typename T,
typename FirstOrderT>
303 typename std::enable_if<!std::is_base_of<Edge, T>::value,
bool>::type
305 const unsigned short incoming_side,
306 Point & intersection_point,
307 unsigned short & intersected_side,
309 Real & intersection_distance,
310 const Point * normals);
327 template <
typename T,
typename FirstOrderT>
328 typename std::enable_if<std::is_base_of<Edge, T>::value,
bool>::type
330 const unsigned short incoming_side,
331 Point & intersection_point,
332 unsigned short & intersected_side,
334 Real & intersection_distance,
335 const Point * normals);
346 const Elem * last_elem,
347 const Elem *& best_elem,
348 unsigned short & best_elem_incoming_side);
361 unsigned short & incoming_side,
362 Point & intersection_point,
363 unsigned short & intersected_side,
365 Real & intersection_distance);
390 const unsigned short side,
391 const std::vector<BoundaryID> & bnd_ids,
414 const Elem *& boundary_elem);
502 std::unordered_map<std::pair<const Node *, const Node *>,
503 std::pair<bool, std::vector<NeighborInfo>>>
532 #ifdef DEBUG_RAY_MESH_IF 541 #define traceAssert(asserted, msg) ((void)0) 543 #define traceAssert(asserted, msg) \ 547 mooseAssert(asserted, failTraceMessage(msg, __LINE__)); \ const std::vector< NeighborInfo > & getPointNeighbors(const Elem *elem, const Point &point)
Get the point neighbors.
const Point & currentIntersectionPoint() const
Gets the current intersection point for the Ray that is being traced.
const std::vector< NeighborInfo > & getEdgeNeighbors(const Elem *elem, const std::pair< const Node *, const Node *> &vertices, const Point &point)
Get the neighbors at an edge.
RayTracingStudy & _study
The RayTracingStudy.
void setBackfaceCulling(const bool backface_culling)
Enable or disable the use of element normals for backface culling through the getElemNormals() method...
ExitsElemResult exitsElem(const Elem *elem, const ElemType elem_type, const unsigned short incoming_side, Point &intersection_point, unsigned short &intersected_side, ElemExtrema &intersected_extrema, Real &intersection_distance, const Point *normals)
Determines if _current_ray moving in direction _direction exits elem.
unsigned short _current_elem_n_sides
The number of sides on the current elem, used to avoid elem->n_sides() virtual calls.
std::unordered_map< std::pair< const Node *, const Node * >, std::pair< bool, std::vector< NeighborInfo > > > _edge_neighbors
The cached edge neighbors.
ElemExtrema _intersected_extrema
The work point for the intersected vertex/edge vertices of the current Ray, if any.
void onTrajectoryChanged(const std::shared_ptr< Ray > &ray)
Called when a Ray's trajectory changes.
void findExternalBoundarySide(unsigned short &boundary_side, ElemExtrema &boundary_extrema, const Elem *&boundary_elem)
Finds (if any) an element side that is on the boundary and is outgoing at _intersection_point that is...
void applyOnExternalBoundary(const std::shared_ptr< Ray > &ray)
Gets and applies external boundary conditions in _current_elem on side _intersected_side at _intersec...
std::vector< std::size_t > _on_boundary_apply_index
Reusable for which boundary elements to apply for a specific RayBC in onBoundary() ...
libMesh::ElemType _current_elem_type
The current elem type (constant on subdomain), used to avoid elem->type() calls.
void onSegment(const std::shared_ptr< Ray > &ray)
Called on a single segment traced by a Ray.
std::string failTraceMessage(const std::string &reason, const int line=-1)
Creates a useful error string with current tracing information.
Data structure that stores information for output of a partial trace of a Ray on a processor...
void onContinueTrace(const std::shared_ptr< Ray > &)
Called when a Ray is continuing to trace after segment.
unsigned int _debug_node_count
void onSubdomainChanged(const std::shared_ptr< Ray > &ray, const bool same_ray)
Called when the subdomain changes.
Base class for a MooseObject used in ray tracing.
MooseUtils::StaticallyAllocatedSet< const Elem *, MAX_POINT_NEIGHBORS > _neighbor_set
void possiblyAddToBoundaryElems(const Elem *elem, const unsigned short side, const std::vector< BoundaryID > &bnd_ids, const ElemExtrema &extrema)
Helper for possibly storing boundary information in _boundary_elems, which is storage for boundary el...
Base object for the RayKernel syntax.
Helper for defining if at an element's edge, vertex, or neither.
Parallel::Communicator _debug_comm
const Elem *const & currentElem() const
Gets the element that the current Ray is being traced in.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
Struct for containing the necessary information about a cached neighbor for ray tracing.
ElemExtrema _last_intersected_extrema
The intersected vertex/edge vertices for the previous intersection, if any.
const unsigned int _dim
The mesh dimension.
void postRayTracingObject(const std::shared_ptr< Ray > &ray, const RayTracingObject *rto)
Called after executing a RayTracingObject (RayBCs and RayKernels)
bool _backface_culling
Whether or not to use element normals for backface culling.
void onBoundary(const std::shared_ptr< Ray > &ray, const bool external)
Called when a Ray hits a boundary.
const SubdomainID & currentSubdomainID() const
Gets the subdomain of the current element that the Ray is being traced in.
void trace(const std::shared_ptr< Ray > &ray)
Traces a ray.
libMesh::ElemSideBuilder _elem_side_builder
Helper for building element sides without excessive allocation.
Point _incoming_point
The incoming point of the current Ray.
const Point * _current_normals
The normals for the current element for backface culling (pointer to the first normal - optional) ...
const Point & currentIncomingPoint() const
Gets the current incoming point for the Ray that is being traced.
uint8_t processor_id_type
bool _exits_elem
Whether or not the current trace exits an element.
unsigned short _incoming_side
The incoming side of the current Ray.
std::vector< BoundaryID > _boundary_ids
Reusable vector for calling _boundary_info.boundary_ids()
Real subdomainHmax(const Elem *elem) const
Get the approximate subdomain hmax for an element.
const unsigned short & currentIntersectedSide() const
Gets the side that the current Ray intersected.
std::set< RayKernelBase * > _old_ray_kernels
Helper for avoiding calling preTrace() on the same RayKernel multiple times.
boundary_id_type BoundaryID
const processor_id_type _pid
The processor id.
void preExecute()
Should be called immediately before calling any traces.
const unsigned short & currentIncomingSide() const
Gets the current incoming side for the Ray that is being traced.
MooseMesh & _mesh
The MooseMesh.
bool _has_ray_kernels
Whether or not the RayTracingStudy has any RayKernels.
std::vector< unsigned long long int > _results
Results over all of the local traces, indexed by TraceRayResult.
ExitsElemResult moveThroughNeighbor(const NeighborInfo &neighbor_info, unsigned short &incoming_side, Point &intersection_point, unsigned short &intersected_side, ElemExtrema &intersected_extrema, Real &intersection_distance)
Sees if a Ray can move through a neighbor (vertex/edge/point)
const Elem * _last_elem
The last element the current Ray was traced in.
ExitsElemResult moveThroughNeighbors(const std::vector< NeighborInfo > &neighbors, const Elem *last_elem, const Elem *&best_elem, unsigned short &best_elem_incoming_side)
Moves the Ray though neighbors (vertex/edge/point)
Basic datastructure for a ray that will traverse the mesh.
TraceData * _current_cached_trace
The TraceData for the current cached trace (if any)
void onCompleteTrace(const std::shared_ptr< Ray > &ray)
Called when a Ray is finished tracing (whenever !ray->shouldContinue())
TraceRay(RayTracingStudy &study, const THREAD_ID tid)
std::vector< const Elem * > _neighbor_active_neighbor_children
std::vector< RayBoundaryConditionBase * > _on_boundary_ray_bcs
Reusable for getting the RayBCs in onBoundary()
const std::shared_ptr< Ray > * _current_ray
The current ray being traced.
TraceRayResult
Enum for the various results reported by this object.
const Elem * _current_elem
The element the current Ray is being traced in.
bool _is_rectangular_domain
Whether or not the domain is rectangular (defined perfectly by its bounding box)
const BoundaryID & currentBoundaryID() const
Gets the BoundaryID of the boundary that the Ray intersected and is being applied a boundary conditio...
const std::vector< NeighborInfo > & getNeighbors(const Elem *elem, const ElemExtrema &extrema, const Point &point)
Get the point/vertex/edge neighbors depending on extrema.
const Real & currentIntersectionDistance() const
Gets the current intersection distance for the Ray that is being traced.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< TraceRayBndElement > _boundary_elems
Boundary elements that need RayBCs to be applied.
const THREAD_ID _tid
The thread id.
void applyOnInternalBoundary(const std::shared_ptr< Ray > &ray)
Gets and applies internal boundary conditions (if any) from _current_elem, _last_elem, and any other point neighbors that have internal sidesets at _intersection_point.
MooseUtils::StaticallyAllocatedSet< const Elem *, MAX_POINT_NEIGHBORS > _neighbor_next_untested_set
std::unordered_map< const Node *, std::vector< NeighborInfo > > _vertex_neighbors
The cached vertex neighbors.
void failTrace(const std::string &reason, const bool warning, const int line=-1)
Specialized mooseError for a failed Ray trace with detailed information regarding the trace...
MooseUtils::StaticallyAllocatedSet< const Elem *, MAX_POINT_NEIGHBORS > _neighbor_untested_set
Real _current_subdomain_hmax
The current subdomain hmax.
ExitsElemResult
Enum for the different exit results for exitElem()
std::vector< unsigned long long int > results() const
Get the various results reported by this object, indexed by TraceRayResult.
unsigned short _intersected_side
The work point for the intersected side of the current Ray.
SubdomainID _current_subdomain_id
The current SubdomainID.
const BoundaryInfo & _boundary_info
The BoundaryInfo for the mesh.
BoundaryID _current_bnd_id
The current BoundaryID (used when calling RayBoundaryConditionBase::onBoundary()) ...
const std::vector< NeighborInfo > & getVertexNeighbors(const Elem *elem, const Node *vertex)
Gets the neighbors at a vertex.
const std::shared_ptr< Ray > *const & currentRay() const
Gets the current Ray that is being traced.
Base class for the RayBC syntax.
void continueTraceOffProcessor(const std::shared_ptr< Ray > &ray)
Sets up a ray to continue tracing off processor.
Real _intersection_distance
The work point for the intersection distance of the current Ray.
const ElemExtrema & currentIntersectedExtrema() const
Gets the element extrema (vertex/edge) that the current Ray intersected.
void meshChanged()
Called on mesh change.
std::vector< NeighborInfo > _point_neighbor_helper
Reusable for building neighbors.
Traces Rays through the mesh on a single processor.
void storeExitsElemResult(const ExitsElemResult result)
Stores the result given by an intersection in _results as necessary.
bool _should_continue
Whether or not the current Ray should continue.
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
Point _intersection_point
The work point for the intersection of the current Ray.