https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RayTracingStudy.h
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#pragma once
11
12#include "GeneralUserObject.h"
13
14// Local Includes
15#include "ElemIndexHelper.h"
16#include "ParallelRayStudy.h"
18#include "TraceData.h"
19#include "TraceRayBndElement.h"
20
21// MOOSE Includes
22#include "TheWarehouse.h"
23
24// libMesh includes
25#include "libmesh/mesh.h"
26#include "libmesh/elem_side_builder.h"
27
28// Forward Declarations
30class RayKernelBase;
31class TraceRay;
33
41{
42public:
44
54 {
55 friend class Parallel::Packing<std::shared_ptr<Ray>>;
56 friend void dataLoad(std::istream & stream, std::shared_ptr<Ray> & ray, void * context);
59 };
60
72
74
75 virtual void initialSetup() override;
76 virtual void residualSetup() override;
77 virtual void jacobianSetup() override;
78 virtual void meshChanged() override;
79 virtual void timestepSetup() override;
80 virtual void initialize() override {}
81 virtual void finalize() override {}
82
86 virtual void execute() override;
87
94 virtual void
95 segmentSubdomainSetup(const SubdomainID subdomain, const THREAD_ID tid, const RayID ray_id);
96
105 virtual void reinitSegment(
106 const Elem * elem, const Point & start, const Point & end, const Real length, THREAD_ID tid);
107
113 virtual void postOnSegment(const THREAD_ID tid, const std::shared_ptr<Ray> & ray);
114
120 virtual void preTrace(const THREAD_ID /* tid */, const std::shared_ptr<Ray> & /* ray */) {}
121
125 void executeStudy();
126
130 unsigned long long int endingProcessorCrossings() const { return _ending_processor_crossings; }
138 unsigned long long int totalProcessorCrossings() const { return _total_processor_crossings; }
142 unsigned int maxProcessorCrossings() const { return _max_processor_crossings; }
143
147 unsigned long long int endingIntersections() const { return _ending_intersections; }
151 unsigned int endingMaxIntersections() const { return _ending_max_intersections; }
155 unsigned long long int totalIntersections() const { return _total_intersections; }
159 unsigned int maxIntersections() const { return _max_intersections; }
163 unsigned int maxTrajectoryChanges() const { return _max_trajectory_changes; }
164
168 Real endingDistance() const { return _ending_distance; }
172 Real totalDistance() const { return _total_distance; }
173
174 unsigned long long int localTraceRayResult(const int result) const
175 {
176 return _local_trace_ray_results[result];
177 }
178
180
184 Real rayMaxDistance() const { return _ray_max_distance; }
185
189 Real executionTime() { return std::chrono::duration<Real>(_execution_time).count(); }
194 {
195 return std::chrono::duration<Real, std::nano>(_execution_time).count();
196 }
200 Real generationTime() const { return std::chrono::duration<Real>(_generation_time).count(); }
204 Real propagationTime() const { return std::chrono::duration<Real>(_propagation_time).count(); }
205
209 bool tolerateFailure() const { return _tolerate_failure; }
210
215
220
229 RayDataIndex registerRayData(const std::string & name);
238 std::vector<RayDataIndex> registerRayData(const std::vector<std::string> & names);
246 RayDataIndex getRayDataIndex(const std::string & name, const bool graceful = false) const;
254 std::vector<RayDataIndex> getRayDataIndices(const std::vector<std::string> & names,
255 const bool graceful = false) const;
261 const std::string & getRayDataName(const RayDataIndex index) const;
267 std::vector<std::string> getRayDataNames(const std::vector<RayDataIndex> & indices) const;
268
272 std::size_t rayDataSize() const { return _ray_data_names.size(); }
276 bool hasRayData() const { return _ray_data_names.size(); }
280 const std::vector<std::string> & rayDataNames() const { return _ray_data_names; }
281
290 RayDataIndex registerRayAuxData(const std::string & name);
299 std::vector<RayDataIndex> registerRayAuxData(const std::vector<std::string> & names);
307 RayDataIndex getRayAuxDataIndex(const std::string & name, const bool graceful = false) const;
315 std::vector<RayDataIndex> getRayAuxDataIndices(const std::vector<std::string> & names,
316 const bool graceful = false) const;
322 const std::string & getRayAuxDataName(const RayDataIndex index) const;
328 std::vector<std::string> getRayAuxDataNames(const std::vector<RayDataIndex> & indices) const;
332 std::size_t rayAuxDataSize() const { return _ray_aux_data_names.size(); }
336 bool hasRayAuxData() const { return _ray_aux_data_names.size(); }
340 const std::vector<std::string> & rayAuxDataNames() const { return _ray_aux_data_names; }
341
345 bool hasRayKernels(const THREAD_ID tid);
349 void getRayKernels(std::vector<RayKernelBase *> & result, SubdomainID id, THREAD_ID tid);
353 template <typename T>
354 void getRayKernels(std::vector<T *> & result, THREAD_ID tid)
355 {
357 .query()
358 .condition<AttribRayTracingStudy>(this)
359 .condition<AttribSystem>("RayKernel")
360 .condition<AttribThread>(tid)
361 .queryInto(result);
362 }
366 void
367 getRayKernels(std::vector<RayKernelBase *> & result, SubdomainID id, THREAD_ID tid, RayID ray_id);
371 void getRayBCs(std::vector<RayBoundaryConditionBase *> & result, BoundaryID id, THREAD_ID tid);
375 template <typename T>
376 void getRayBCs(std::vector<T *> & result, const std::vector<BoundaryID> & ids, THREAD_ID tid)
377 {
379 .query()
380 .condition<AttribRayTracingStudy>(this)
381 .condition<AttribSystem>("RayBoundaryCondition")
382 .condition<AttribBoundaries>(ids)
383 .condition<AttribThread>(tid)
384 .queryInto(result);
385 }
389 template <typename T>
390 void getRayBCs(std::vector<T *> & result, THREAD_ID tid)
391 {
393 .query()
394 .condition<AttribRayTracingStudy>(this)
395 .condition<AttribSystem>("RayBoundaryCondition")
396 .condition<AttribThread>(tid)
397 .queryInto(result);
398 }
406 virtual void getRayBCs(std::vector<RayBoundaryConditionBase *> & result,
407 const std::vector<TraceRayBndElement> & bnd_elems,
408 THREAD_ID tid,
409 RayID ray_id);
410
414 const std::vector<RayKernelBase *> & currentRayKernels(THREAD_ID tid) const
415 {
417 }
418
422 const BoundingBox & boundingBox() const { return _b_box; }
429 const BoundingBox & looseBoundingBox() const { return _loose_b_box; }
433 Real domainMaxLength() const { return _domain_max_length; }
437 Real totalVolume() const { return _total_volume; }
441 bool isRectangularDomain() const;
442
449 bool hasInternalSidesets() const { return _internal_sidesets.size(); }
455 const std::vector<std::vector<BoundaryID>> & getInternalSidesets(const Elem * elem) const;
459 const std::set<BoundaryID> & getInternalSidesets() const { return _internal_sidesets; }
465 bool sideIsNonPlanar(const Elem * elem, const unsigned short s) const
466 {
468 }
476
487 std::shared_ptr<Ray> acquireRayDuringTrace(const THREAD_ID tid,
488 const AcquireMoveDuringTraceKey &);
489 std::shared_ptr<Ray> acquireRayInternal(const RayID id,
490 const std::size_t data_size,
491 const std::size_t aux_data_size,
492 const bool reset,
493 const AcquireRayInternalKey &)
494 {
495 return _parallel_ray_study->acquireParallelData(
496 0, this, id, data_size, aux_data_size, reset, Ray::ConstructRayKey());
497 }
499
507 void moveRayToBufferDuringTrace(std::shared_ptr<Ray> & ray,
508 const THREAD_ID tid,
509 const AcquireMoveDuringTraceKey &);
515 MeshBase & meshBase() const { return _mesh; }
516
520 MooseMesh & mesh() { return _mesh; }
521
525 virtual const Point &
526 getSideNormal(const Elem * elem, const unsigned short side, const THREAD_ID tid);
531 virtual const Point * getElemNormals(const Elem * /* elem */, const THREAD_ID /* tid */)
532 {
533 mooseError("Unimplemented element normal caching in ", type(), "::getElemNormals()");
534 }
535
541 RayData getBankedRayData(const RayID ray_id, const RayDataIndex index) const;
547 RayData getBankedRayAuxData(const RayID ray_id, const RayDataIndex index) const;
548
554 RayID registeredRayID(const std::string & name, const bool graceful = false) const;
559 const std::string & registeredRayName(const RayID ray_id) const;
560
565
578
583 virtual bool shouldCacheTrace(const std::shared_ptr<Ray> & /* ray */) const
584 {
586 }
587
591 TraceData & initThreadedCachedTrace(const std::shared_ptr<Ray> & ray, THREAD_ID tid);
595 const std::vector<TraceData> & getCachedTraces() const { return _cached_traces; }
596
602 Real subdomainHmax(const SubdomainID subdomain_id) const;
603
607 virtual void onCompleteRay(const std::shared_ptr<Ray> & ray);
608
617 void verifyUniqueRayIDs(const std::vector<std::shared_ptr<Ray>>::const_iterator begin,
618 const std::vector<std::shared_ptr<Ray>>::const_iterator end,
619 const bool global,
620 const std::string & error_suffix) const;
621
630 void verifyUniqueRays(const std::vector<std::shared_ptr<Ray>>::const_iterator begin,
631 const std::vector<std::shared_ptr<Ray>>::const_iterator end,
632 const std::string & error_suffix);
633
637 bool currentlyPropagating() const { return _parallel_ray_study->currentlyExecuting(); }
641 bool currentlyGenerating() const { return _parallel_ray_study->currentlyPreExecuting(); }
642
647 TraceRay & traceRay(const THREAD_ID tid) { return *_threaded_trace_ray[tid]; }
648 const TraceRay & traceRay(const THREAD_ID tid) const { return *_threaded_trace_ray[tid]; }
650
654 bool verifyRays() const { return _verify_rays; }
658#ifndef NDEBUG
660#endif
661
665 bool sideIsIncoming(const Elem * const elem,
666 const unsigned short side,
667 const Point & direction,
668 const THREAD_ID tid);
669
673 bool warnNonPlanar() const { return _warn_non_planar; }
674
679
688 const libMesh::Elem &
689 elemSide(const libMesh::Elem & elem, const unsigned int s, const THREAD_ID tid = 0)
690 {
691 return _threaded_elem_side_builders[tid](elem, s);
692 }
693
694protected:
700 virtual void generateRays() = 0;
701
705 virtual void preExecuteStudy() {}
709 virtual void postExecuteStudy() {}
710
714 Real computeTotalVolume();
715
721 std::vector<RayKernelBase *> & currentRayKernelsWrite(THREAD_ID tid)
722 {
724 }
725
732 void reserveRayBuffer(const std::size_t size);
733
738 bool sameLevelActiveElems() const;
739
748 virtual void buildSegmentQuadrature(const Point & start,
749 const Point & end,
750 const Real length,
751 std::vector<Point> & points,
752 std::vector<Real> & weights) const;
753
761 const std::vector<std::shared_ptr<Ray>> & rayBank() const;
762
771 std::shared_ptr<Ray> getBankedRay(const RayID ray_id) const;
772
777 void resetUniqueRayIDs();
782
786 std::vector<RayTracingObject *> getRayTracingObjects();
787
793 virtual RayID generateUniqueRayID(const THREAD_ID tid);
798
805
811 std::shared_ptr<Ray> acquireRay();
818 std::shared_ptr<Ray> acquireUnsizedRay();
827 std::shared_ptr<Ray> acquireReplicatedRay();
834 std::shared_ptr<Ray> acquireCopiedRay(const Ray & ray);
842 std::shared_ptr<Ray> acquireRegisteredRay(const std::string & name);
844
851 void moveRayToBuffer(std::shared_ptr<Ray> & ray);
858 void moveRaysToBuffer(std::vector<std::shared_ptr<Ray>> & rays);
859
863 const Parallel::Communicator & _comm;
865 const processor_id_type _pid;
866
881
893 const bool _verify_rays;
895#ifndef NDEBUG
897#endif
898
899private:
903 void coverageChecks();
904
908 void dependencyChecks();
912 void verifyDependenciesExist(const std::vector<RayTracingObject *> & rtos);
913
917 void traceableMeshChecks();
918
925
939
948 void nonPlanarSideSetup();
949
957 void localElemIndexSetup();
958
964 void registeredRaySetup();
965
969 void zeroAuxVariables();
970
974 void subdomainHMaxSetup();
975
979 RayDataIndex registerRayDataInternal(const std::string & name, const bool aux);
983 std::vector<RayDataIndex> registerRayDataInternal(const std::vector<std::string> & names,
984 const bool aux);
989 getRayDataIndexInternal(const std::string & name, const bool aux, const bool graceful) const;
993 std::vector<RayDataIndex> getRayDataIndicesInternal(const std::vector<std::string> & names,
994 const bool aux,
995 const bool graceful) const;
996
1000 const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const;
1001
1006 RayData
1007 getBankedRayDataInternal(const RayID ray_id, const RayDataIndex index, const bool aux) const;
1008
1018 RayID registerRay(const std::string & name);
1019
1021 std::vector<libMesh::ElemSideBuilder> _threaded_elem_side_builders;
1022
1024
1025 std::chrono::steady_clock::time_point _execution_start_time;
1026 std::chrono::steady_clock::duration _execution_time;
1027 std::chrono::steady_clock::duration _generation_time;
1028 std::chrono::steady_clock::duration _propagation_time;
1030
1032 std::unordered_map<std::string, RayDataIndex> _ray_data_map;
1034 std::unordered_map<std::string, RayDataIndex> _ray_aux_data_map;
1035
1037 std::vector<std::string> _ray_data_names;
1039 std::vector<std::string> _ray_aux_data_names;
1040
1042 std::unordered_map<std::string, RayID> & _registered_ray_map;
1044 std::vector<std::string> & _reverse_registered_ray_map;
1045
1047 std::vector<TraceData> _cached_traces;
1049 std::vector<std::vector<TraceData>> _threaded_cached_traces;
1050
1052 std::vector<std::size_t> _num_cached;
1053
1055 std::set<BoundaryID> _internal_sidesets;
1057 std::vector<std::vector<std::vector<BoundaryID>>> _internal_sidesets_map;
1062 std::vector<std::vector<unsigned short>> _non_planar_sides;
1065
1074
1076 std::vector<TheWarehouse::QueryCache<AttribSubdomains>> _threaded_cache_ray_kernel;
1078 std::vector<TheWarehouse::QueryCache<AttribBoundaries>> _threaded_cache_ray_bc;
1080 std::vector<std::vector<std::set<const RayTracingObject *>>> _threaded_ray_object_registration;
1082 std::vector<std::vector<RayKernelBase *>> _threaded_current_ray_kernels;
1084 std::vector<std::shared_ptr<TraceRay>> _threaded_trace_ray;
1086 std::vector<std::unique_ptr<libMesh::FEBase>> _threaded_fe_face;
1088 std::vector<std::unique_ptr<libMesh::QBase>> _threaded_q_face;
1090 std::vector<std::unordered_map<std::pair<const Elem *, unsigned short>, Point>>
1093 std::vector<std::shared_ptr<Ray>> _ray_bank;
1095 std::vector<RayID> _threaded_next_ray_id;
1098
1100 const std::unique_ptr<ParallelRayStudy> _parallel_ray_study;
1101
1103 std::unique_ptr<libMesh::QBase> _segment_qrule;
1104
1106 unsigned long long int _ending_processor_crossings;
1110 unsigned long long int _total_processor_crossings;
1113
1115 unsigned long long int _ending_intersections;
1121 unsigned long long int _total_intersections;
1126
1131
1133 std::vector<unsigned long long int> _local_trace_ray_results;
1134
1136 std::unordered_map<SubdomainID, Real> _subdomain_hmax;
1137
1140
1143
1145 mutable Threads::spin_mutex _spin_mutex;
1146};
boundary_id_type BoundaryID
unsigned int THREAD_ID
unsigned int RayDataIndex
Type for the index into the data and aux data on a Ray.
Definition Ray.h:52
unsigned long int RayID
Type for a Ray's ID.
Definition Ray.h:44
float RayData
Type for a Ray's data.
Definition Ray.h:47
Attribute for the RayTracingStudy a RayTracingObject is associated with.
Helper for setting up a contiguous index for a given range of elements that are known by this process...
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
TheWarehouse & theWarehouse() const
const InputParameters & parameters() const
const std::string & type() const
const std::string & name() const
void mooseError(Args &&... args) const
Base class for the RayBC syntax.
Base object for the RayKernel syntax.
Base class for a MooseObject used in ray tracing.
Key that is used for restricting access to moveRayToBufferDuringTrace() and acquireRayDuringTrace().
AcquireMoveDuringTraceKey(const AcquireMoveDuringTraceKey &)
Key that is used for restricting access to acquireRayInternal().
AcquireRayInternalKey(const AcquireRayInternalKey &)
friend void dataLoad(std::istream &stream, std::shared_ptr< Ray > &ray, void *context)
Definition Ray.C:738
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
unsigned int _ending_max_intersections
Max number of intersections for Rays that finished on this processor.
bool _has_same_level_active_elems
Whether or not the mesh has active elements of the same level.
void moveRayToBufferDuringTrace(std::shared_ptr< Ray > &ray, const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
INTERNAL method for moving a Ray into the buffer during tracing.
MeshBase & meshBase() const
Access to the libMesh MeshBase.
const bool _data_on_cache_traces
Whether or not to store the Ray data on the cache traces.
virtual void finalize() override
bool sideIsNonPlanar(const Elem *elem, const unsigned short s) const
Whether or not the side \s on elem elem is non-planar.
void traceableMeshChecks()
Check for if all of the element types in the mesh are supported by ray tracing.
std::vector< TheWarehouse::QueryCache< AttribSubdomains > > _threaded_cache_ray_kernel
Threaded cached subdomain query for RayKernelBase objects pertaining to this study.
std::shared_ptr< Ray > acquireCopiedRay(const Ray &ray)
Acquires a Ray that that is copied from another Ray within generateRays().
std::vector< TheWarehouse::QueryCache< AttribBoundaries > > _threaded_cache_ray_bc
Threaded cached boundary query for RayBC objects pertaining to this study.
const bool _verify_rays
Whether or not to verify if Rays have valid information before being traced.
void verifyDependenciesExist(const std::vector< RayTracingObject * > &rtos)
Verifies that the dependencies exist for a set of RayTracingObjects.
const bool _use_internal_sidesets
Whether or not to use the internal sidesets in ray tracing.
const bool _ray_dependent_subdomain_setup
Whether or not subdomain setup is dependent on the Ray.
const Real _ray_max_distance
Max distance a Ray can travel before being killed (can change)
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
std::unordered_map< std::string, RayDataIndex > _ray_aux_data_map
The map from Ray aux data names to index.
RayDataIndex registerRayAuxData(const std::string &name)
Register a value to be filled in the aux data on a Ray with a given name.
bool warnNonPlanar() const
Whether or not to produce a warning when interacting with a non-planar mesh.
unsigned int endingMaxIntersections() const
Max number of intersections for Rays that finished on this processor.
const std::vector< RayKernelBase * > & currentRayKernels(THREAD_ID tid) const
Gets the current RayKernels for a thread, which are set in segmentSubdomainSetup()
std::vector< unsigned long long int > _local_trace_ray_results
Cumulative results on this processor from the threaded TraceRay objects.
bool sideIsIncoming(const Elem *const elem, const unsigned short side, const Point &direction, const THREAD_ID tid)
Whether or not side is incoming on element elem in direction direction.
void resetUniqueRayIDs()
Resets the generation of unique RayIDs via generateUniqueRayID() to the beginning of the range.
Real _ending_distance
Total distance traveled by Rays that end on this processor.
std::shared_ptr< Ray > acquireRegisteredRay(const std::string &name)
Acquires a Ray with a given name within generateRays().
const bool _tolerate_failure
Whether or not to tolerate a Ray Tracing failure.
std::chrono::steady_clock::duration _generation_time
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
std::vector< std::string > _ray_aux_data_names
The names for each Ray aux data entry.
void getRayKernels(std::vector< RayKernelBase * > &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.
void verifyUniqueRays(const std::vector< std::shared_ptr< Ray > >::const_iterator begin, const std::vector< std::shared_ptr< Ray > >::const_iterator end, const std::string &error_suffix)
Verifies that the Rays in the given range are unique.
std::size_t rayDataSize() const
The registered size of values in the Ray data.
RayDataIndex registerRayData(const std::string &name)
Register a value to be filled in the data on a Ray with a given name.
TraceData & initThreadedCachedTrace(const std::shared_ptr< Ray > &ray, THREAD_ID tid)
Initialize a Ray in the threaded cached trace map to be filled with segments.
void getRayBCs(std::vector< T * > &result, THREAD_ID tid)
Fills the active RayBCs associated with this study into result.
Real executionTimeNano()
Duration for execute() in nanoseconds.
std::vector< std::vector< std::vector< BoundaryID > > > _internal_sidesets_map
Internal sideset data, if internal sidesets exist (indexed with getLocalElemIndex())
std::vector< std::shared_ptr< Ray > > _ray_bank
Cumulative Ray bank - stored only when _bank_rays_on_completion.
void nonPlanarSideSetup()
Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar...
std::chrono::steady_clock::duration _propagation_time
Real generationTime() const
Duration for creation of all Rays in seconds.
unsigned long long int totalProcessorCrossings() const
Total number of processor crossings.
virtual void initialSetup() override
bool sameLevelActiveElems() const
Determine whether or not the mesh currently has active elements that are all the same level.
virtual const Point * getElemNormals(const Elem *, const THREAD_ID)
Gets the outward normals for a given element.
const std::vector< TraceData > & getCachedTraces() const
Get the cached trace data structure.
const libMesh::Elem & elemSide(const libMesh::Elem &elem, const unsigned int s, const THREAD_ID tid=0)
Get an element's side pointer without excessive memory allocation.
virtual void initialize() override
std::set< BoundaryID > _internal_sidesets
The BoundaryIDs on the local mesh that have internal RayBCs.
bool _has_non_planar_sides
Whether or not the local mesh has elements with non-planar sides.
unsigned int _ending_max_processor_crossings
Max number of total processor crossings for Rays that finished on this processor.
std::vector< std::unique_ptr< libMesh::QBase > > _threaded_q_face
Face quadrature used for computing face normals for each thread.
unsigned int maxTrajectoryChanges() const
Max number of trajectory changes for a Ray.
const bool _use_ray_registration
Whether or not to use Ray registration.
const bool _segments_on_cache_traces
Whether or not to cache individual element segments when caching.
const std::vector< std::string > & rayAuxDataNames() const
The Ray aux data names.
static InputParameters validParams()
bool currentlyGenerating() const
Whether or not the study is generating.
MooseMesh & _mesh
The Mesh.
std::shared_ptr< Ray > getBankedRay(const RayID ray_id) const
Gets the Ray with the ID ray_id from the Ray bank.
const std::vector< std::string > & rayDataNames() const
The Ray data names.
void subdomainHMaxSetup()
Caches the hmax for all elements in each subdomain.
void localElemIndexSetup()
Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that ...
RayID registerRay(const std::string &name)
Registers a Ray with a given name.
std::vector< std::string > _ray_data_names
The names for each Ray data entry.
unsigned long long int _total_intersections
Total number of Ray/element intersections.
void getRayBCs(std::vector< T * > &result, const std::vector< BoundaryID > &ids, THREAD_ID tid)
Fills the active RayBCs associated with this study and boundaries result.
std::shared_ptr< Ray > acquireRayDuringTrace(const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
INTERNAL methods for acquiring a Ray during a trace in RayKernels and RayBCs.
Real _total_distance
Total distance traveled by all Rays.
unsigned int endingMaxProcessorCrossings() const
Max number of total processor crossings for Rays that finished on this processor.
unsigned long long int _ending_processor_crossings
Total number of processor crossings for Rays that finished on this processor.
std::vector< std::unordered_map< std::pair< const Elem *, unsigned short >, Point > > _threaded_cached_normals
Threaded cache for side normals that have been computed already during tracing.
RayID _replicated_next_ray_id
Storage for the next available replicated RayID, obtained via generateReplicatedRayID()
void resetReplicatedRayIDs()
Resets the generation of unique replicated RayIDs accessed via generateReplicatedRayID().
const std::string & getRayAuxDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray aux data.
const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const
Internal method for getting the name of Ray data or Ray aux data.
virtual void segmentSubdomainSetup(const SubdomainID subdomain, const THREAD_ID tid, const RayID ray_id)
Setup for on subdomain change or subdomain AND ray change during ray tracing.
virtual void preExecuteStudy()
Entry point before study execution.
RayData getBankedRayData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
const bool _verify_trace_intersections
Whether or not to verify the trace intersections in devel and dbg modes.
MooseMesh & mesh()
Real totalDistance() const
Total distance traveled by all Rays.
const ParallelRayStudy & parallelRayStudy() const
virtual void residualSetup() override
std::vector< TraceData > _cached_traces
Storage for the cached traces.
unsigned int _max_trajectory_changes
Max number of trajectory changes for a single Ray.
virtual void reinitSegment(const Elem *elem, const Point &start, const Point &end, const Real length, THREAD_ID tid)
Reinitialize objects for a Ray segment for ray tracing.
virtual void generateRays()=0
Subclasses should override this to determine how to generate Rays.
std::vector< RayDataIndex > getRayAuxDataIndices(const std::vector< std::string > &names, const bool graceful=false) const
Gets the indices associated with registered values in the Ray aux data.
const bool _bank_rays_on_completion
Whether or not to bank rays on completion.
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.
unsigned long long int endingProcessorCrossings() const
Total number of processor crossings for Rays that finished on this processor.
std::vector< RayID > _threaded_next_ray_id
Storage for the next available unique RayID, obtained via generateUniqueRayID()
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
Real executionTime()
Duration for execute() in seconds.
Real computeTotalVolume()
Helper function for computing the total domain volume.
std::unordered_map< std::string, RayID > & _registered_ray_map
Map from registered Ray name to ID.
Real _domain_max_length
An inflated max distance for the domain.
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.
virtual void postOnSegment(const THREAD_ID tid, const std::shared_ptr< Ray > &ray)
Called at the end of a Ray segment.
libMesh::BoundingBox _loose_b_box
Loose nodal bounding box for the domain.
void internalSidesetSetup()
Does the setup for internal sidesets.
virtual void buildSegmentQuadrature(const Point &start, const Point &end, const Real length, std::vector< Point > &points, std::vector< Real > &weights) const
Builds quadrature points for a given segment using the _segment_qrule.
unsigned long long int _ending_intersections
Total number of Ray/element intersections for Rays that finished on this processor.
bool _always_cache_traces
Whether or not to cache traces on every trace execution.
std::shared_ptr< Ray > acquireReplicatedRay()
Acquire a Ray from the pool of Rays within generateRays() in a replicated fashion.
virtual void execute() override
Executes the study (generates and propagates Rays)
Real endingDistance() const
Total amount of distance traveled by the rays that end on this processor.
virtual void postExecuteStudy()
Entry point after study execution.
unsigned int _max_intersections
Max number of intersections for a single Ray.
bool useRayRegistration() const
Whether or not ray registration is being used.
bool isRectangularDomain() const
Whether or not the domain is rectangular (if it is prefectly encompassed by its bounding box)
const bool _aux_data_on_cache_traces
Whether or not to store the Ray aux data on the cache traces.
std::shared_ptr< Ray > acquireUnsizedRay()
Acquire a Ray from the pool of Rays within generateRays(), without resizing the data (sizes the data ...
bool segmentsOnCacheTraces() const
Whether or not to cache individual element segments when _cache_traces = true.
void registeredRaySetup()
Sets up the maps from Ray to associated RayTracingObjects if _use_ray_registration.
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
bool bankRaysOnCompletion() const
Whether or not to bank Rays on completion.
const bool _ray_kernel_coverage_check
Whether or not to perform coverage checks on RayKernels.
Real domainMaxLength() const
Get the inflated maximum length across the domain.
const BoundingBox & looseBoundingBox() const
Get the loose nodal bounding box for the domain.
Real propagationTime() const
Duration for creation of all Rays in seconds.
std::unique_ptr< libMesh::QBase > _segment_qrule
Quadrature rule for laying points across a 1D ray segment.
virtual void jacobianSetup() override
TraceRay & traceRay(const THREAD_ID tid)
Gets the threaded TraceRay object for tid.
std::vector< std::string > getRayAuxDataNames(const std::vector< RayDataIndex > &indices) const
Gets the names associated with registered values in the Ray aux data.
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a ray to the buffer to be traced during generateRays().
const std::string & registeredRayName(const RayID ray_id) const
Gets the name of a registered ray.
std::vector< RayKernelBase * > & currentRayKernelsWrite(THREAD_ID tid)
Gets the writeable current RayKernels for a thread.
void reserveRayBuffer(const std::size_t size)
Reserve size entires in the Ray buffer.
void verifyUniqueRayIDs(const std::vector< std::shared_ptr< Ray > >::const_iterator begin, const std::vector< std::shared_ptr< Ray > >::const_iterator end, const bool global, const std::string &error_suffix) const
Verifies that the Rays in the given range have unique Ray IDs.
bool hasRayAuxData() const
Whether or not any Ray aux data are registered.
std::unordered_map< SubdomainID, Real > _subdomain_hmax
The cached hmax for all elements in a subdomain.
bool verifyRays() const
Whether or not to verify if Rays have valid information before being traced.
RayID registeredRayID(const std::string &name, const bool graceful=false) const
Gets the ID of a registered ray.
virtual const Point & getSideNormal(const Elem *elem, const unsigned short side, const THREAD_ID tid)
Get the outward normal for a given element side.
virtual void meshChanged() override
Real _total_volume
The total volume of the domain.
unsigned long long int _total_processor_crossings
Total number of processor crossings.
Real rayMaxDistance() const
Max distance any Ray can travel.
std::vector< std::vector< TraceData > > _threaded_cached_traces
The threaded storage for cached traces.
bool rayDependentSubdomainSetup() const
Whether or not to use Ray dependent subdomain setup.
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)
RayID generateReplicatedRayID()
Generates a Ray ID that is replicated across all processors.
bool auxDataOnCacheTraces() const
Whether or not to store the Ray aux data on the cached Ray traces.
bool hasRayData() const
Whether or not any Ray data are registered.
bool hasSameLevelActiveElems() const
Whether or not the mesh has active elements of the same level.
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
unsigned long long int endingIntersections() const
Total number of Ray/element intersections for Rays that finished on this processor.
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
Real totalVolume() const
Get the current total volume of the domain.
unsigned int maxIntersections() const
Max number of intersections for a Ray.
const std::string & getRayDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray data.
std::chrono::steady_clock::duration _execution_time
unsigned int maxProcessorCrossings() const
Max number of processor crossings for all Rays.
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
virtual void timestepSetup() override
ParallelStudy< std::shared_ptr< Ray >, Ray > * parallelStudy()
The underlying parallel study: used for the context for calling the packed range routines.
RayData getBankedRayAuxData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
virtual void preTrace(const THREAD_ID, const std::shared_ptr< Ray > &)
Called at the beginning of a trace for a ray.
std::unordered_map< std::string, RayDataIndex > _ray_data_map
The map from Ray data names to index.
const std::vector< std::shared_ptr< Ray > > & rayBank() const
Get the Ray bank.
std::vector< std::vector< std::set< const RayTracingObject * > > > _threaded_ray_object_registration
Threaded storage for all of the RayTracingObjects associated with a single Ray.
virtual RayID generateUniqueRayID(const THREAD_ID tid)
Generates a unique RayID to be used for a Ray.
std::vector< std::vector< unsigned short > > _non_planar_sides
Non planar side data, which is for quick checking if an elem side is non-planar We use unsigned short...
void coverageChecks()
Perform coverage checks (coverage of RayMaterials and RayKernels, if enabled)
const std::set< BoundaryID > & getInternalSidesets() const
Gets the internal sidesets (that have RayBCs) within the local domain.
virtual bool shouldCacheTrace(const std::shared_ptr< Ray > &) const
Virtual that allows for selection in if a Ray should be cached or not (only used when _cache_traces).
Real subdomainHmax(const SubdomainID subdomain_id) const
Get the cached hmax for all elements in a subdomain.
unsigned int _ending_max_trajectory_changes
Max number of trajectory changes for Rays that finished on this processor.
void getRayKernels(std::vector< T * > &result, THREAD_ID tid)
Fills the active RayKernels associated with this study into result.
RayDataIndex getRayDataIndexInternal(const std::string &name, const bool aux, const bool graceful) const
Internal method for getting the index of Ray data or Ray aux data.
bool hasInternalSidesets() const
Whether or not the local mesh has internal sidesets that have RayBCs on them.
RayDataIndex getRayAuxDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray aux data.
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 verifyTraceIntersections() const
Whether or not trace verification is enabled in devel/dbg modes.
libMesh::BoundingBox _b_box
Nodal bounding box for the domain.
unsigned long long int localTraceRayResult(const int result) const
unsigned long long int totalIntersections() const
Total number of Ray/element intersections.
void getRayBCs(std::vector< RayBoundaryConditionBase * > &result, BoundaryID id, THREAD_ID tid)
Fills the active RayBCs associated with this study and a boundary into result.
std::vector< libMesh::ElemSideBuilder > _threaded_elem_side_builders
Threaded helpers for building element sides without extraneous allocation.
std::vector< RayDataIndex > getRayDataIndices(const std::vector< std::string > &names, const bool graceful=false) const
Gets the indices associated with registered values in the Ray data.
std::vector< RayDataIndex > getRayDataIndicesInternal(const std::vector< std::string > &names, const bool aux, const bool graceful) const
Internal method for getting the indicies of Ray data or Ray aux data.
void moveRaysToBuffer(std::vector< std::shared_ptr< Ray > > &rays)
Moves rays to the buffer to be traced during generateRays().
void dependencyChecks()
Perform checks to see if the listed dependencies in the RayTracingObjects exist.
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once)
const TraceRay & traceRay(const THREAD_ID tid) const
virtual void onCompleteRay(const std::shared_ptr< Ray > &ray)
Entry point for acting on a ray when it is completed (shouldContinue() == false)
std::vector< std::string > getRayDataNames(const std::vector< RayDataIndex > &indices) const
Gets the names associated with registered values in the Ray data.
std::vector< std::unique_ptr< libMesh::FEBase > > _threaded_fe_face
Face FE used for computing face normals for each thread.
const BoundingBox & boundingBox() const
Get the nodal bounding box for the domain.
bool _called_initial_setup
Whether or not we've called initial setup - used to stop from late registration.
const Parallel::Communicator & _comm
The Communicator.
RayData getBankedRayDataInternal(const RayID ray_id, const RayDataIndex index, const bool aux) const
Internal method for getting the value (replicated across all processors) in a Ray's data or aux data ...
std::vector< std::string > & _reverse_registered_ray_map
Map from registered Ray ID to name.
void periodicBoundaryChecks()
Check for overlapping PeriodicRayBC boundaries and check for cases in which ghosting may not be suffi...
bool tolerateFailure() const
Whether or not to tolerate failure.
bool hasRayKernels(const THREAD_ID tid)
Whether or not there are currently any active RayKernel objects.
void executeStudy()
Method for executing the study so that it can be called out of the standard UO execute()
unsigned int _max_processor_crossings
Max number of processor crossings for all Rays.
std::chrono::steady_clock::time_point _execution_start_time
Timing.
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
void zeroAuxVariables()
Zero the AuxVariables that the registered AuxRayKernels contribute to.
const bool _warn_non_planar
Whether not to warn if non-planar faces are found.
bool dataOnCacheTraces() const
Whether or not to store the Ray data on the cached Ray traces.
Class that is used as a parameter to the public constructors/reset methods.
Definition Ray.h:100
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58
Query query()
Traces Rays through the mesh on a single processor.
Definition TraceRay.h:47
FEProblemBase & _fe_problem
Data structure that stores information for output of a partial trace of a Ray on a processor.
Definition TraceData.h:43