https://mooseframework.inl.gov
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"
17 #include "RayTracingAttributes.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
30 class RayKernelBase;
31 class TraceRay;
32 class RayTracingObject;
33 
41 {
42 public:
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 
66  {
68  friend class RayKernelBase;
71  };
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 
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 
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  {
416  return _threaded_current_ray_kernels[tid];
417  }
418 
422  const BoundingBox & boundingBox() const { return _b_box; }
429  const BoundingBox & looseBoundingBox() const { return _loose_b_box; }
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 
486  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 
564  bool useRayRegistration() const { return _use_ray_registration; }
565 
569  bool dataOnCacheTraces() const { return _data_on_cache_traces; }
578 
583  virtual bool shouldCacheTrace(const std::shared_ptr<Ray> & /* ray */) const
584  {
585  return _always_cache_traces;
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 
646  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 
694 protected:
700  virtual void generateRays() = 0;
701 
705  virtual void preExecuteStudy() {}
709  virtual void postExecuteStudy() {}
710 
715 
721  std::vector<RayKernelBase *> & currentRayKernelsWrite(THREAD_ID tid)
722  {
723  return _threaded_current_ray_kernels[tid];
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();
781  void resetReplicatedRayIDs();
782 
786  std::vector<RayTracingObject *> getRayTracingObjects();
787 
793  virtual RayID generateUniqueRayID(const THREAD_ID tid);
798 
804 
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;
866 
870  const bool _warn_non_planar;
876  const bool _tolerate_failure;
881 
893  const bool _verify_rays;
895 #ifndef NDEBUG
897 #endif
898 
899 private:
903  void coverageChecks();
904 
908  void dependencyChecks();
912  void verifyDependenciesExist(const std::vector<RayTracingObject *> & rtos);
913 
917  void traceableMeshChecks();
918 
931  void internalSidesetSetup();
932 
941  void nonPlanarSideSetup();
942 
950  void localElemIndexSetup();
951 
957  void registeredRaySetup();
958 
962  void zeroAuxVariables();
963 
967  void subdomainHMaxSetup();
968 
972  RayDataIndex registerRayDataInternal(const std::string & name, const bool aux);
976  std::vector<RayDataIndex> registerRayDataInternal(const std::vector<std::string> & names,
977  const bool aux);
982  getRayDataIndexInternal(const std::string & name, const bool aux, const bool graceful) const;
986  std::vector<RayDataIndex> getRayDataIndicesInternal(const std::vector<std::string> & names,
987  const bool aux,
988  const bool graceful) const;
989 
993  const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const;
994 
999  RayData
1000  getBankedRayDataInternal(const RayID ray_id, const RayDataIndex index, const bool aux) const;
1001 
1011  RayID registerRay(const std::string & name);
1012 
1014  std::vector<libMesh::ElemSideBuilder> _threaded_elem_side_builders;
1015 
1017 
1018  std::chrono::steady_clock::time_point _execution_start_time;
1019  std::chrono::steady_clock::duration _execution_time;
1020  std::chrono::steady_clock::duration _generation_time;
1021  std::chrono::steady_clock::duration _propagation_time;
1023 
1025  std::unordered_map<std::string, RayDataIndex> _ray_data_map;
1027  std::unordered_map<std::string, RayDataIndex> _ray_aux_data_map;
1028 
1030  std::vector<std::string> _ray_data_names;
1032  std::vector<std::string> _ray_aux_data_names;
1033 
1035  std::unordered_map<std::string, RayID> & _registered_ray_map;
1037  std::vector<std::string> & _reverse_registered_ray_map;
1038 
1040  std::vector<TraceData> _cached_traces;
1042  std::vector<std::vector<TraceData>> _threaded_cached_traces;
1043 
1045  std::vector<std::size_t> _num_cached;
1046 
1048  std::set<BoundaryID> _internal_sidesets;
1050  std::vector<std::vector<std::vector<BoundaryID>>> _internal_sidesets_map;
1055  std::vector<std::vector<unsigned short>> _non_planar_sides;
1058 
1067 
1069  std::vector<TheWarehouse::QueryCache<AttribSubdomains>> _threaded_cache_ray_kernel;
1071  std::vector<TheWarehouse::QueryCache<AttribBoundaries>> _threaded_cache_ray_bc;
1073  std::vector<std::vector<std::set<const RayTracingObject *>>> _threaded_ray_object_registration;
1075  std::vector<std::vector<RayKernelBase *>> _threaded_current_ray_kernels;
1077  std::vector<std::shared_ptr<TraceRay>> _threaded_trace_ray;
1079  std::vector<std::unique_ptr<libMesh::FEBase>> _threaded_fe_face;
1081  std::vector<std::unique_ptr<libMesh::QBase>> _threaded_q_face;
1083  std::vector<std::unordered_map<std::pair<const Elem *, unsigned short>, Point>>
1086  std::vector<std::shared_ptr<Ray>> _ray_bank;
1088  std::vector<RayID> _threaded_next_ray_id;
1091 
1093  const std::unique_ptr<ParallelRayStudy> _parallel_ray_study;
1094 
1096  std::unique_ptr<libMesh::QBase> _segment_qrule;
1097 
1099  unsigned long long int _ending_processor_crossings;
1103  unsigned long long int _total_processor_crossings;
1106 
1108  unsigned long long int _ending_intersections;
1114  unsigned long long int _total_intersections;
1116  unsigned int _max_intersections;
1119 
1124 
1126  std::vector<unsigned long long int> _local_trace_ray_results;
1127 
1129  std::unordered_map<SubdomainID, Real> _subdomain_hmax;
1130 
1133 
1136 
1138  mutable Threads::spin_mutex _spin_mutex;
1139 };
bool hasRayKernels(const THREAD_ID tid)
Whether or not there are currently any active RayKernel objects.
ParallelStudy< std::shared_ptr< Ray >, Ray > * parallelStudy()
The underlying parallel study: used for the context for calling the packed range routines.
bool currentlyGenerating() const
Whether or not the study is generating.
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 internalSidesetSetup()
Does the setup for internal sidesets.
RayDataIndex registerRayData(const std::string &name)
Register a value to be filled in the data on a Ray with a given name.
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&#39;s data or aux data ...
virtual void postOnSegment(const THREAD_ID tid, const std::shared_ptr< Ray > &ray)
Called at the end of a Ray segment.
const bool _tolerate_failure
Whether or not to tolerate a Ray Tracing failure.
Real totalVolume() const
Get the current total volume of the domain.
void traceableMeshChecks()
Check for if all of the element types in the mesh are supported by ray tracing.
virtual void onCompleteRay(const std::shared_ptr< Ray > &ray)
Entry point for acting on a ray when it is completed (shouldContinue() == false)
const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const
Internal method for getting the name of Ray data or Ray aux data.
bool hasRayData() const
Whether or not any Ray data are registered.
bool segmentsOnCacheTraces() const
Whether or not to cache individual element segments when _cache_traces = true.
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.
std::vector< std::string > & _reverse_registered_ray_map
Map from registered Ray ID to name.
unsigned int maxProcessorCrossings() const
Max number of processor crossings for all Rays.
unsigned long long int _total_intersections
Total number of Ray/element intersections.
auto reset(int, T &obj, Args... args) -> decltype(obj.reset(args...), void())
RayID registerRay(const std::string &name)
Registers a Ray with a given name.
unsigned long long int _ending_intersections
Total number of Ray/element intersections for Rays that finished on this processor.
unsigned int _max_trajectory_changes
Max number of trajectory changes for a single Ray.
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
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 _has_same_level_active_elems
Whether or not the mesh has active elements of the same level.
bool sameLevelActiveElems() const
Determine whether or not the mesh currently has active elements that are all the same level...
bool hasSameLevelActiveElems() const
Whether or not the mesh has active elements of the same level.
const ParallelRayStudy & parallelRayStudy() const
virtual void initialSetup() override
void moveRayToBufferDuringTrace(std::shared_ptr< Ray > &ray, const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
INTERNAL method for moving a Ray into the buffer during tracing.
RayDataIndex registerRayAuxData(const std::string &name)
Register a value to be filled in the aux data on a Ray with a given name.
const bool _segments_on_cache_traces
Whether or not to cache individual element segments when caching.
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
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.
MooseMesh & _mesh
The Mesh.
Attribute for the RayTracingStudy a RayTracingObject is associated with.
std::vector< std::vector< TraceData > > _threaded_cached_traces
The threaded storage for cached traces.
const bool _use_internal_sidesets
Whether or not to use the internal sidesets in ray tracing.
Data structure that stores information for output of a partial trace of a Ray on a processor...
Definition: TraceData.h:42
const Real _ray_max_distance
Max distance a Ray can travel before being killed (can change)
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
const BoundingBox & looseBoundingBox() const
Get the loose nodal bounding box for the domain.
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
std::unordered_map< SubdomainID, Real > _subdomain_hmax
The cached hmax for all elements in a subdomain.
const std::vector< TraceData > & getCachedTraces() const
Get the cached trace data structure.
const std::vector< std::string > & rayDataNames() const
The Ray data names.
unsigned long long int totalProcessorCrossings() const
Total number of processor crossings.
libMesh::BoundingBox _loose_b_box
Loose nodal bounding box for the domain.
Base class for a MooseObject used in ray tracing.
const std::set< BoundaryID > & getInternalSidesets() const
Gets the internal sidesets (that have RayBCs) within the local domain.
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...
RayData getBankedRayData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
Base object for the RayKernel syntax.
Definition: RayKernelBase.h:27
bool useRayRegistration() const
Whether or not ray registration is being used.
Real executionTime()
Duration for execute() in seconds.
Real _ending_distance
Total distance traveled by Rays that end on this processor.
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.
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.
const std::vector< RayKernelBase * > & currentRayKernels(THREAD_ID tid) const
Gets the current RayKernels for a thread, which are set in segmentSubdomainSetup() ...
const bool _verify_trace_intersections
Whether or not to verify the trace intersections in devel and dbg modes.
Key that is used for restricting access to moveRayToBufferDuringTrace() and acquireRayDuringTrace().
virtual void finalize() override
std::shared_ptr< Ray > acquireReplicatedRay()
Acquire a Ray from the pool of Rays within generateRays() in a replicated fashion.
void getRayBCs(std::vector< T *> &result, THREAD_ID tid)
Fills the active RayBCs associated with this study into 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.
std::shared_ptr< Ray > acquireRegisteredRay(const std::string &name)
Acquires a Ray with a given name within generateRays().
Real rayMaxDistance() const
Max distance any Ray can travel.
RayID _replicated_next_ray_id
Storage for the next available replicated RayID, obtained via generateReplicatedRayID() ...
std::set< BoundaryID > _internal_sidesets
The BoundaryIDs on the local mesh that have internal RayBCs.
virtual RayID generateUniqueRayID(const THREAD_ID tid)
Generates a unique RayID to be used for a Ray.
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.
virtual const std::string & name() const
std::vector< std::string > getRayAuxDataNames(const std::vector< RayDataIndex > &indices) const
Gets the names associated with registered values in the Ray aux data.
unsigned int endingMaxIntersections() const
Max number of intersections for Rays that finished on this processor.
unsigned int maxTrajectoryChanges() const
Max number of trajectory changes for a Ray.
std::vector< TraceData > _cached_traces
Storage for the cached traces.
const BoundingBox & boundingBox() const
Get the nodal bounding box for the domain.
RayDataIndex getRayAuxDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray aux data.
AcquireMoveDuringTraceKey(const AcquireMoveDuringTraceKey &)
TraceRay & traceRay(const THREAD_ID tid)
Gets the threaded TraceRay object for tid.
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)
Real subdomainHmax(const SubdomainID subdomain_id) const
Get the cached hmax for all elements in a subdomain.
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()
bool isRectangularDomain() const
Whether or not the domain is rectangular (if it is prefectly encompassed by its bounding box) ...
std::vector< std::string > _ray_aux_data_names
The names for each Ray aux data entry.
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
uint8_t processor_id_type
const bool _ray_dependent_subdomain_setup
Whether or not subdomain setup is dependent on the Ray.
std::shared_ptr< Ray > getBankedRay(const RayID ray_id) const
Gets the Ray with the ID ray_id from the Ray bank.
unsigned long long int _total_processor_crossings
Total number of processor crossings.
void nonPlanarSideSetup()
Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar...
bool verifyTraceIntersections() const
Whether or not trace verification is enabled in devel/dbg modes.
bool verifyRays() const
Whether or not to verify if Rays have valid information before being traced.
unsigned int RayDataIndex
Type for the index into the data and aux data on a Ray.
Definition: Ray.h:51
void coverageChecks()
Perform coverage checks (coverage of RayMaterials and RayKernels, if enabled)
void resetReplicatedRayIDs()
Resets the generation of unique replicated RayIDs accessed via generateReplicatedRayID().
const bool _data_on_cache_traces
Whether or not to store the Ray data on the cache traces.
const bool _bank_rays_on_completion
Whether or not to bank rays on completion.
unsigned int _ending_max_intersections
Max number of intersections for Rays that finished on this processor.
TheWarehouse & theWarehouse() const
virtual void postExecuteStudy()
Entry point after study execution.
bool auxDataOnCacheTraces() const
Whether or not to store the Ray aux data on the cached Ray traces.
unsigned int _max_processor_crossings
Max number of processor crossings for all Rays.
bool _always_cache_traces
Whether or not to cache traces on every trace execution.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
friend void dataLoad(std::istream &stream, std::shared_ptr< Ray > &ray, void *context)
Definition: Ray.C:724
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
Real endingDistance() const
Total amount of distance traveled by the rays that end on this processor.
AcquireRayInternalKey(const AcquireRayInternalKey &)
virtual void residualSetup() override
boundary_id_type BoundaryID
std::vector< TheWarehouse::QueryCache< AttribSubdomains > > _threaded_cache_ray_kernel
Threaded cached subdomain query for RayKernelBase objects pertaining to this study.
virtual void execute() override
Executes the study (generates and propagates Rays)
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 &)
unsigned int _max_intersections
Max number of intersections for a single Ray.
unsigned int _ending_max_trajectory_changes
Max number of trajectory changes for Rays that finished on this processor.
unsigned int _ending_max_processor_crossings
Max number of total processor crossings for Rays that finished on this processor. ...
const std::string & getRayDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray data.
void reserveRayBuffer(const std::size_t size)
Reserve size entires in the Ray buffer.
void zeroAuxVariables()
Zero the AuxVariables that the registered AuxRayKernels contribute to.
std::vector< std::unique_ptr< libMesh::FEBase > > _threaded_fe_face
Face FE used for computing face normals for each thread.
const std::string & type() const
void dependencyChecks()
Perform checks to see if the listed dependencies in the RayTracingObjects exist.
Key that is used for restricting access to acquireRayInternal().
static InputParameters validParams()
const std::string & getRayAuxDataName(const RayDataIndex index) const
Gets the name associated with a registered value in the Ray aux data.
bool rayDependentSubdomainSetup() const
Whether or not to use Ray dependent subdomain setup.
Basic datastructure for a ray that will traverse the mesh.
Definition: Ray.h:56
std::chrono::steady_clock::time_point _execution_start_time
Timing.
std::vector< TheWarehouse::QueryCache< AttribBoundaries > > _threaded_cache_ray_bc
Threaded cached boundary query for RayBC objects pertaining to this study.
virtual void jacobianSetup() override
virtual void preExecuteStudy()
Entry point before study execution.
std::unordered_map< std::string, RayDataIndex > _ray_aux_data_map
The map from Ray aux data names to index.
bool sideIsNonPlanar(const Elem *elem, const unsigned short s) const
Whether or not the side on elem elem is non-planar.
const bool _warn_non_planar
Whether not to warn if non-planar faces are found.
libMesh::BoundingBox _b_box
Nodal bounding box for the domain.
const std::vector< std::string > & rayAuxDataNames() const
The Ray aux data names.
virtual void meshChanged() override
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
virtual void generateRays()=0
Subclasses should override this to determine how to generate Rays.
RayID generateReplicatedRayID()
Generates a Ray ID that is replicated across all processors.
virtual const Point * getElemNormals(const Elem *, const THREAD_ID)
Gets the outward normals for a given element.
unsigned long long int endingIntersections() const
Total number of Ray/element intersections for Rays that finished on this processor.
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.
void verifyDependenciesExist(const std::vector< RayTracingObject *> &rtos)
Verifies that the dependencies exist for a set of RayTracingObjects.
unsigned long long int _ending_processor_crossings
Total number of processor crossings for Rays that finished on this processor.
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
RayTracingStudy(const InputParameters &parameters)
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.
Real _domain_max_length
An inflated max distance for the domain.
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.
Real _total_volume
The total volume of the domain.
virtual const Point & getSideNormal(const Elem *elem, const unsigned short side, const THREAD_ID tid)
Get the outward normal for a given element side.
bool hasRayAuxData() const
Whether or not any Ray aux data are registered.
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.
std::unordered_map< std::string, RayDataIndex > _ray_data_map
The map from Ray data names to index.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _aux_data_on_cache_traces
Whether or not to store the Ray aux data on the cache traces.
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.
bool warnNonPlanar() const
Whether or not to produce a warning when interacting with a non-planar mesh.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
bool _has_non_planar_sides
Whether or not the local mesh has elements with non-planar sides.
const libMesh::Elem & elemSide(const libMesh::Elem &elem, const unsigned int s, const THREAD_ID tid=0)
Get an element&#39;s side pointer without excessive memory allocation.
const bool _verify_rays
Whether or not to verify if Rays have valid information before being traced.
FEProblemBase & _fe_problem
Helper for setting up a contiguous index for a given range of elements that are known by this process...
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< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
virtual void preTrace(const THREAD_ID, const std::shared_ptr< Ray > &)
Called at the beginning of a trace for a ray.
const TraceRay & traceRay(const THREAD_ID tid) const
std::chrono::steady_clock::duration _propagation_time
Query query()
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.
bool bankRaysOnCompletion() const
Whether or not to bank Rays on completion.
unsigned long long int localTraceRayResult(const int result) const
RayData getBankedRayAuxData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
std::vector< std::string > getRayDataNames(const std::vector< RayDataIndex > &indices) const
Gets the names associated with registered values in the Ray data.
class infix_ostream_iterator if void
Real executionTimeNano()
Duration for execute() in nanoseconds.
unsigned int endingMaxProcessorCrossings() const
Max number of total processor crossings for Rays that finished on this processor. ...
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::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 mooseError(Args &&... args) const
Real _total_distance
Total distance traveled by all Rays.
MeshBase & meshBase() const
Access to the libMesh MeshBase.
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once) ...
const InputParameters & parameters() const
std::unordered_map< std::string, RayID > & _registered_ray_map
Map from registered Ray name to ID.
std::vector< std::string > _ray_data_names
The names for each Ray data entry.
float RayData
Type for a Ray&#39;s data.
Definition: Ray.h:46
const std::string & registeredRayName(const RayID ray_id) const
Gets the name of a registered ray.
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a ray to the buffer to be traced during generateRays().
const Parallel::Communicator & _comm
The Communicator.
RayID registeredRayID(const std::string &name, const bool graceful=false) const
Gets the ID of a registered ray.
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.
virtual void initialize() override
const bool _use_ray_registration
Whether or not to use Ray registration.
const bool _ray_kernel_coverage_check
Whether or not to perform coverage checks on RayKernels.
void localElemIndexSetup()
Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that ...
Real generationTime() const
Duration for creation of all Rays in seconds.
bool tolerateFailure() const
Whether or not to tolerate failure.
std::vector< std::shared_ptr< Ray > > _ray_bank
Cumulative Ray bank - stored only when _bank_rays_on_completion.
std::vector< unsigned long long int > _local_trace_ray_results
Cumulative results on this processor from the threaded TraceRay objects.
std::chrono::steady_clock::duration _generation_time
void registeredRaySetup()
Sets up the maps from Ray to associated RayTracingObjects if _use_ray_registration.
void moveRaysToBuffer(std::vector< std::shared_ptr< Ray >> &rays)
Moves rays to the buffer to be traced during generateRays().
void executeStudy()
Method for executing the study so that it can be called out of the standard UO execute() ...
Base class for the RayBC syntax.
std::vector< libMesh::ElemSideBuilder > _threaded_elem_side_builders
Threaded helpers for building element sides without extraneous allocation.
unsigned int maxIntersections() const
Max number of intersections for a Ray.
Real totalDistance() const
Total distance traveled by all Rays.
std::shared_ptr< Ray > acquireUnsizedRay()
Acquire a Ray from the pool of Rays within generateRays(), without resizing the data (sizes the data ...
void getRayKernels(std::vector< T *> &result, THREAD_ID tid)
Fills the active RayKernels associated with this study into result.
bool dataOnCacheTraces() const
Whether or not to store the Ray data on the cached Ray traces.
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
MooseMesh & mesh()
void resetUniqueRayIDs()
Resets the generation of unique RayIDs via generateUniqueRayID() to the beginning of the range...
std::chrono::steady_clock::duration _execution_time
std::vector< std::unique_ptr< libMesh::QBase > > _threaded_q_face
Face quadrature used for computing face normals for each thread.
std::shared_ptr< Ray > acquireCopiedRay(const Ray &ray)
Acquires a Ray that that is copied from another Ray within generateRays().
Traces Rays through the mesh on a single processor.
Definition: TraceRay.h:46
std::vector< std::vector< std::vector< BoundaryID > > > _internal_sidesets_map
Internal sideset data, if internal sidesets exist (indexed with getLocalElemIndex()) ...
void subdomainHMaxSetup()
Caches the hmax for all elements in each subdomain.
Real domainMaxLength() const
Get the inflated maximum length across the domain.
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.
unsigned long long int totalIntersections() const
Total number of Ray/element intersections.
std::vector< RayKernelBase * > & currentRayKernelsWrite(THREAD_ID tid)
Gets the writeable current RayKernels for a thread.
std::unique_ptr< libMesh::QBase > _segment_qrule
Quadrature rule for laying points across a 1D ray segment.
bool hasInternalSidesets() const
Whether or not the local mesh has internal sidesets that have RayBCs on them.
std::size_t rayDataSize() const
The registered size of values in the Ray data.
unsigned int THREAD_ID
virtual void timestepSetup() override
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
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 propagationTime() const
Duration for creation of all Rays in seconds.
Real computeTotalVolume()
Helper function for computing the total domain volume.