https://mooseframework.inl.gov
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
RayTracingStudy Class Referenceabstract

Base class for Ray tracing studies that will generate Rays and then propagate all of them to termination. More...

#include <RayTracingStudy.h>

Inheritance diagram for RayTracingStudy:
[legend]

Classes

class  AcquireMoveDuringTraceKey
 Key that is used for restricting access to moveRayToBufferDuringTrace() and acquireRayDuringTrace(). More...
 
class  AcquireRayInternalKey
 Key that is used for restricting access to acquireRayInternal(). More...
 

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 RayTracingStudy (const InputParameters &parameters)
 
virtual void initialSetup () override
 
virtual void residualSetup () override
 
virtual void jacobianSetup () override
 
virtual void meshChanged () override
 
virtual void timestepSetup () override
 
virtual void initialize () override
 
virtual void finalize () override
 
virtual void execute () override
 Executes the study (generates and propagates Rays) More...
 
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. More...
 
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. More...
 
virtual void postOnSegment (const THREAD_ID tid, const std::shared_ptr< Ray > &ray)
 Called at the end of a Ray segment. More...
 
virtual void preTrace (const THREAD_ID, const std::shared_ptr< Ray > &)
 Called at the beginning of a trace for a ray. More...
 
void executeStudy ()
 Method for executing the study so that it can be called out of the standard UO execute() More...
 
unsigned long long int endingProcessorCrossings () const
 Total number of processor crossings for Rays that finished on this processor. More...
 
unsigned int endingMaxProcessorCrossings () const
 Max number of total processor crossings for Rays that finished on this processor. More...
 
unsigned long long int totalProcessorCrossings () const
 Total number of processor crossings. More...
 
unsigned int maxProcessorCrossings () const
 Max number of processor crossings for all Rays. More...
 
unsigned long long int endingIntersections () const
 Total number of Ray/element intersections for Rays that finished on this processor. More...
 
unsigned int endingMaxIntersections () const
 Max number of intersections for Rays that finished on this processor. More...
 
unsigned long long int totalIntersections () const
 Total number of Ray/element intersections. More...
 
unsigned int maxIntersections () const
 Max number of intersections for a Ray. More...
 
unsigned int maxTrajectoryChanges () const
 Max number of trajectory changes for a Ray. More...
 
Real endingDistance () const
 Total amount of distance traveled by the rays that end on this processor. More...
 
Real totalDistance () const
 Total distance traveled by all Rays. More...
 
unsigned long long int localTraceRayResult (const int result) const
 
const ParallelRayStudyparallelRayStudy () const
 
Real rayMaxDistance () const
 Max distance any Ray can travel. More...
 
Real executionTime ()
 Duration for execute() in seconds. More...
 
Real executionTimeNano ()
 Duration for execute() in nanoseconds. More...
 
Real generationTime () const
 Duration for creation of all Rays in seconds. More...
 
Real propagationTime () const
 Duration for creation of all Rays in seconds. More...
 
bool tolerateFailure () const
 Whether or not to tolerate failure. More...
 
bool bankRaysOnCompletion () const
 Whether or not to bank Rays on completion. More...
 
bool rayDependentSubdomainSetup () const
 Whether or not to use Ray dependent subdomain setup. More...
 
RayDataIndex registerRayData (const std::string &name)
 Register a value to be filled in the data on a Ray with a given name. More...
 
std::vector< RayDataIndexregisterRayData (const std::vector< std::string > &names)
 Register values to be filled in the data on a Ray with a given name. More...
 
RayDataIndex getRayDataIndex (const std::string &name, const bool graceful=false) const
 Gets the index associated with a registered value in the Ray data. More...
 
std::vector< RayDataIndexgetRayDataIndices (const std::vector< std::string > &names, const bool graceful=false) const
 Gets the indices associated with registered values in the Ray data. More...
 
const std::string & getRayDataName (const RayDataIndex index) const
 Gets the name associated with a registered value in the Ray data. More...
 
std::vector< std::string > getRayDataNames (const std::vector< RayDataIndex > &indices) const
 Gets the names associated with registered values in the Ray data. More...
 
std::size_t rayDataSize () const
 The registered size of values in the Ray data. More...
 
bool hasRayData () const
 Whether or not any Ray data are registered. More...
 
const std::vector< std::string > & rayDataNames () const
 The Ray data names. More...
 
RayDataIndex registerRayAuxData (const std::string &name)
 Register a value to be filled in the aux data on a Ray with a given name. More...
 
std::vector< RayDataIndexregisterRayAuxData (const std::vector< std::string > &names)
 Register values to be filled in the aux data on a Ray with a given name. More...
 
RayDataIndex getRayAuxDataIndex (const std::string &name, const bool graceful=false) const
 Gets the index associated with a registered value in the Ray aux data. More...
 
std::vector< RayDataIndexgetRayAuxDataIndices (const std::vector< std::string > &names, const bool graceful=false) const
 Gets the indices associated with registered values in the Ray aux data. More...
 
const std::string & getRayAuxDataName (const RayDataIndex index) const
 Gets the name associated with a registered value in the Ray aux data. More...
 
std::vector< std::string > getRayAuxDataNames (const std::vector< RayDataIndex > &indices) const
 Gets the names associated with registered values in the Ray aux data. More...
 
std::size_t rayAuxDataSize () const
 The registered size of values in the Ray aux data. More...
 
bool hasRayAuxData () const
 Whether or not any Ray aux data are registered. More...
 
const std::vector< std::string > & rayAuxDataNames () const
 The Ray aux data names. More...
 
bool hasRayKernels (const THREAD_ID tid)
 Whether or not there are currently any active RayKernel objects. More...
 
void getRayKernels (std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
 Fills the active RayKernels associated with this study and a block into result. More...
 
template<typename T >
void getRayKernels (std::vector< T *> &result, THREAD_ID tid)
 Fills the active RayKernels associated with this study into result. More...
 
void getRayKernels (std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid, RayID ray_id)
 Fills the active RayKernels associeted with this study, block, and potentially Ray into result. More...
 
void getRayBCs (std::vector< RayBoundaryConditionBase *> &result, BoundaryID id, THREAD_ID tid)
 Fills the active RayBCs associated with this study and a boundary into result. More...
 
template<typename T >
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. More...
 
template<typename T >
void getRayBCs (std::vector< T *> &result, THREAD_ID tid)
 Fills the active RayBCs associated with this study into result. More...
 
virtual void getRayBCs (std::vector< RayBoundaryConditionBase *> &result, const std::vector< TraceRayBndElement > &bnd_elems, THREAD_ID tid, RayID ray_id)
 Fills the active RayBCs associated with thie study, boundary elements, and potentially Ray into result. More...
 
const std::vector< RayKernelBase * > & currentRayKernels (THREAD_ID tid) const
 Gets the current RayKernels for a thread, which are set in segmentSubdomainSetup() More...
 
const BoundingBox & boundingBox () const
 Get the nodal bounding box for the domain. More...
 
const BoundingBox & looseBoundingBox () const
 Get the loose nodal bounding box for the domain. More...
 
Real domainMaxLength () const
 Get the inflated maximum length across the domain. More...
 
Real totalVolume () const
 Get the current total volume of the domain. More...
 
bool isRectangularDomain () const
 Whether or not the domain is rectangular (if it is prefectly encompassed by its bounding box) More...
 
bool hasInternalSidesets () const
 Whether or not the local mesh has internal sidesets that have RayBCs on them. More...
 
const std::vector< std::vector< BoundaryID > > & getInternalSidesets (const Elem *elem) const
 Get the internal sidesets (that have RayBC(s)) for each side for a given element. More...
 
const std::set< BoundaryID > & getInternalSidesets () const
 Gets the internal sidesets (that have RayBCs) within the local domain. More...
 
bool sideIsNonPlanar (const Elem *elem, const unsigned short s) const
 Whether or not the side on elem elem is non-planar. More...
 
bool hasSameLevelActiveElems () const
 Whether or not the mesh has active elements of the same level. More...
 
void moveRayToBufferDuringTrace (std::shared_ptr< Ray > &ray, const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
 INTERNAL method for moving a Ray into the buffer during tracing. More...
 
MeshBase & meshBase () const
 Access to the libMesh MeshBase. More...
 
MooseMeshmesh ()
 
virtual const PointgetSideNormal (const Elem *elem, const unsigned short side, const THREAD_ID tid)
 Get the outward normal for a given element side. More...
 
virtual const Point * getElemNormals (const Elem *, const THREAD_ID)
 Gets the outward normals for a given element. More...
 
RayData getBankedRayData (const RayID ray_id, const RayDataIndex index) const
 Gets the data value for a banked ray with a given ID. More...
 
RayData getBankedRayAuxData (const RayID ray_id, const RayDataIndex index) const
 Gets the data value for a banked ray with a given ID. More...
 
RayID registeredRayID (const std::string &name, const bool graceful=false) const
 Gets the ID of a registered ray. More...
 
const std::string & registeredRayName (const RayID ray_id) const
 Gets the name of a registered ray. More...
 
bool useRayRegistration () const
 Whether or not ray registration is being used. More...
 
bool dataOnCacheTraces () const
 Whether or not to store the Ray data on the cached Ray traces. More...
 
bool auxDataOnCacheTraces () const
 Whether or not to store the Ray aux data on the cached Ray traces. More...
 
bool segmentsOnCacheTraces () const
 Whether or not to cache individual element segments when _cache_traces = true. More...
 
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). More...
 
TraceDatainitThreadedCachedTrace (const std::shared_ptr< Ray > &ray, THREAD_ID tid)
 Initialize a Ray in the threaded cached trace map to be filled with segments. More...
 
const std::vector< TraceData > & getCachedTraces () const
 Get the cached trace data structure. More...
 
Real subdomainHmax (const SubdomainID subdomain_id) const
 Get the cached hmax for all elements in a subdomain. More...
 
virtual void onCompleteRay (const std::shared_ptr< Ray > &ray)
 Entry point for acting on a ray when it is completed (shouldContinue() == false) More...
 
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. More...
 
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. More...
 
bool currentlyPropagating () const
 Whether or not the study is propagating (tracing Rays) More...
 
bool currentlyGenerating () const
 Whether or not the study is generating. More...
 
bool verifyRays () const
 Whether or not to verify if Rays have valid information before being traced. More...
 
bool verifyTraceIntersections () const
 Whether or not trace verification is enabled in devel/dbg modes. More...
 
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. More...
 
bool warnNonPlanar () const
 Whether or not to produce a warning when interacting with a non-planar mesh. More...
 
ParallelStudy< std::shared_ptr< Ray >, Ray > * parallelStudy ()
 The underlying parallel study: used for the context for calling the packed range routines. More...
 
const libMesh::ElemelemSide (const libMesh::Elem &elem, const unsigned int s, const THREAD_ID tid=0)
 Get an element's side pointer without excessive memory allocation. More...
 
SubProblemgetSubProblem () const
 
bool shouldDuplicateInitialExecution () const
 
virtual Real spatialValue (const Point &) const
 
virtual const std::vector< Point > spatialPoints () const
 
void gatherSum (T &value)
 
void gatherMax (T &value)
 
void gatherMin (T &value)
 
void gatherProxyValueMax (T1 &proxy, T2 &value)
 
void gatherProxyValueMin (T1 &proxy, T2 &value)
 
void setPrimaryThreadCopy (UserObject *primary)
 
UserObjectprimaryThreadCopy ()
 
std::set< UserObjectName > getDependObjects () const
 
virtual bool needThreadedCopy () const
 
const std::set< std::string > & getRequestedItems () override
 
const std::set< std::string > & getSuppliedItems () override
 
unsigned int systemNumber () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const std::vector< MooseVariableScalar *> & getCoupledMooseScalarVars ()
 
const std::set< TagID > & getScalarVariableCoupleableVectorTags () const
 
const std::set< TagID > & getScalarVariableCoupleableMatrixTags () const
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > getBlockMaterialProperty (const MaterialPropertyName &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty ()
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialPropertyByName (const std::string &prop_name)
 
const MaterialProperty< T > & getZeroMaterialProperty (Ts... args)
 
std::set< SubdomainIDgetMaterialPropertyBlocks (const std::string &name)
 
std::vector< SubdomainName > getMaterialPropertyBlockNames (const std::string &name)
 
std::set< BoundaryIDgetMaterialPropertyBoundaryIDs (const std::string &name)
 
std::vector< BoundaryName > getMaterialPropertyBoundaryNames (const std::string &name)
 
void checkBlockAndBoundaryCompatibility (std::shared_ptr< MaterialBase > discrete)
 
std::unordered_map< SubdomainID, std::vector< MaterialBase *> > buildRequiredMaterials (bool allow_stateful=true)
 
void statefulPropertiesAllowed (bool)
 
bool getMaterialPropertyCalled () const
 
virtual const std::unordered_set< unsigned int > & getMatPropDependencies () const
 
virtual void resolveOptionalProperties ()
 
const GenericMaterialProperty< T, is_ad > & getPossiblyConstantGenericMaterialPropertyByName (const MaterialPropertyName &prop_name, MaterialData &material_data, const unsigned int state)
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
virtual void threadJoin (const UserObject &) override
 
virtual void threadJoin (const UserObject &) override
 
virtual void subdomainSetup () override
 
virtual void subdomainSetup () override
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
const FunctiongetFunction (const std::string &name) const
 
const FunctiongetFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
T & getSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 
virtual void meshDisplaced ()
 
PerfGraphperfGraph ()
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
std::shared_ptr< RayacquireRayDuringTrace (const THREAD_ID tid, const AcquireMoveDuringTraceKey &)
 INTERNAL methods for acquiring a Ray during a trace in RayKernels and RayBCs. More...
 
std::shared_ptr< RayacquireRayInternal (const RayID id, const std::size_t data_size, const std::size_t aux_data_size, const bool reset, const AcquireRayInternalKey &)
 
TraceRaytraceRay (const THREAD_ID tid)
 Gets the threaded TraceRay object for tid. More...
 
const TraceRaytraceRay (const THREAD_ID tid) const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void sort (typename std::vector< T > &vector)
 
static void sortDFS (typename std::vector< T > &vector)
 
static void cyclicDependencyError (CyclicDependencyException< T2 > &e, const std::string &header)
 

Public Attributes

const ConsoleStream _console
 

Static Public Attributes

static constexpr PropertyValue::id_type default_property_id
 
static constexpr PropertyValue::id_type zero_property_id
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

virtual void generateRays ()=0
 Subclasses should override this to determine how to generate Rays. More...
 
virtual void preExecuteStudy ()
 Entry point before study execution. More...
 
virtual void postExecuteStudy ()
 Entry point after study execution. More...
 
Real computeTotalVolume ()
 Helper function for computing the total domain volume. More...
 
std::vector< RayKernelBase * > & currentRayKernelsWrite (THREAD_ID tid)
 Gets the writeable current RayKernels for a thread. More...
 
void reserveRayBuffer (const std::size_t size)
 Reserve size entires in the Ray buffer. More...
 
bool sameLevelActiveElems () const
 Determine whether or not the mesh currently has active elements that are all the same level. More...
 
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. More...
 
const std::vector< std::shared_ptr< Ray > > & rayBank () const
 Get the Ray bank. More...
 
std::shared_ptr< RaygetBankedRay (const RayID ray_id) const
 Gets the Ray with the ID ray_id from the Ray bank. More...
 
void resetUniqueRayIDs ()
 Resets the generation of unique RayIDs via generateUniqueRayID() to the beginning of the range. More...
 
void resetReplicatedRayIDs ()
 Resets the generation of unique replicated RayIDs accessed via generateReplicatedRayID(). More...
 
std::vector< RayTracingObject * > getRayTracingObjects ()
 Gets all of the currently active RayTracingObjects. More...
 
virtual RayID generateUniqueRayID (const THREAD_ID tid)
 Generates a unique RayID to be used for a Ray. More...
 
RayID generateReplicatedRayID ()
 Generates a Ray ID that is replicated across all processors. More...
 
void moveRayToBuffer (std::shared_ptr< Ray > &ray)
 Moves a ray to the buffer to be traced during generateRays(). More...
 
void moveRaysToBuffer (std::vector< std::shared_ptr< Ray >> &rays)
 Moves rays to the buffer to be traced during generateRays(). More...
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &name) const override
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &name) const override
 
virtual void addUserObjectDependencyHelper (const UserObject &uo) const override
 
void addReporterDependencyHelper (const ReporterName &reporter_name) override
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
bool isCoupledScalar (const std::string &var_name, unsigned int i=0) const
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 
libMesh::Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< is_ad > & coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< false > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const GenericVariableValue< true > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const VariableValuecoupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 
const MooseVariableScalargetScalarVar (const std::string &var_name, unsigned int comp) const
 
virtual void checkMaterialProperty (const std::string &name, const unsigned int state)
 
void markMatPropRequested (const std::string &)
 
MaterialPropertyName getMaterialPropertyName (const std::string &name) const
 
void checkExecutionStage ()
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
std::shared_ptr< RayacquireRay ()
 User APIs for constructing Rays within the RayTracingStudy. More...
 
std::shared_ptr< RayacquireUnsizedRay ()
 Acquire a Ray from the pool of Rays within generateRays(), without resizing the data (sizes the data to zero). More...
 
std::shared_ptr< RayacquireReplicatedRay ()
 Acquire a Ray from the pool of Rays within generateRays() in a replicated fashion. More...
 
std::shared_ptr< RayacquireCopiedRay (const Ray &ray)
 Acquires a Ray that that is copied from another Ray within generateRays(). More...
 
std::shared_ptr< RayacquireRegisteredRay (const std::string &name)
 Acquires a Ray with a given name within generateRays(). More...
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

MooseMesh_mesh
 The Mesh. More...
 
const Parallel::Communicator & _comm
 The Communicator. More...
 
const processor_id_type _pid
 The rank of this processor (this actually takes time to lookup - so just do it once) More...
 
const bool _ray_kernel_coverage_check
 Whether or not to perform coverage checks on RayKernels. More...
 
const bool _warn_non_planar
 Whether not to warn if non-planar faces are found. More...
 
const bool _use_ray_registration
 Whether or not to use Ray registration. More...
 
const bool _use_internal_sidesets
 Whether or not to use the internal sidesets in ray tracing. More...
 
const bool _tolerate_failure
 Whether or not to tolerate a Ray Tracing failure. More...
 
const bool _bank_rays_on_completion
 Whether or not to bank rays on completion. More...
 
const bool _ray_dependent_subdomain_setup
 Whether or not subdomain setup is dependent on the Ray. More...
 
bool _always_cache_traces
 Whether or not to cache traces on every trace execution. More...
 
const bool _data_on_cache_traces
 Whether or not to store the Ray data on the cache traces. More...
 
const bool _aux_data_on_cache_traces
 Whether or not to store the Ray aux data on the cache traces. More...
 
const bool _segments_on_cache_traces
 Whether or not to cache individual element segments when caching. More...
 
const Real _ray_max_distance
 Max distance a Ray can travel before being killed (can change) More...
 
const bool _verify_rays
 Whether or not to verify if Rays have valid information before being traced. More...
 
const bool _verify_trace_intersections
 Whether or not to verify the trace intersections in devel and dbg modes. More...
 
SubProblem_subproblem
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
const THREAD_ID _tid
 
Assembly_assembly
 
const Moose::CoordinateSystemType_coord_sys
 
const bool _duplicate_initial_execution
 
std::set< std::string > _depend_uo
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
FEProblemBase_mdi_feproblem
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
FEProblemBase_sc_fe_problem
 
const THREAD_ID _sc_tid
 
const Real_real_zero
 
const VariableValue_scalar_zero
 
const Point & _point_zero
 
const InputParameters_mi_params
 
const std::string _mi_name
 
const MooseObjectName _mi_moose_object_name
 
FEProblemBase_mi_feproblem
 
SubProblem_mi_subproblem
 
const THREAD_ID _mi_tid
 
const Moose::MaterialDataType _material_data_type
 
MaterialData_material_data
 
bool _stateful_allowed
 
bool _get_material_property_called
 
std::vector< std::unique_ptr< PropertyValue > > _default_properties
 
std::unordered_set< unsigned int_material_property_dependencies
 
const MaterialPropertyName _get_suffix
 
const bool _use_interpolated_state
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static const std::string _interpolated_old
 
static const std::string _interpolated_older
 

Private Member Functions

void coverageChecks ()
 Perform coverage checks (coverage of RayMaterials and RayKernels, if enabled) More...
 
void dependencyChecks ()
 Perform checks to see if the listed dependencies in the RayTracingObjects exist. More...
 
void verifyDependenciesExist (const std::vector< RayTracingObject *> &rtos)
 Verifies that the dependencies exist for a set of RayTracingObjects. More...
 
void traceableMeshChecks ()
 Check for if all of the element types in the mesh are supported by ray tracing. More...
 
void internalSidesetSetup ()
 Does the setup for internal sidesets. More...
 
void nonPlanarSideSetup ()
 Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar_sides. More...
 
void localElemIndexSetup ()
 Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that this processor knows about. More...
 
void registeredRaySetup ()
 Sets up the maps from Ray to associated RayTracingObjects if _use_ray_registration. More...
 
void zeroAuxVariables ()
 Zero the AuxVariables that the registered AuxRayKernels contribute to. More...
 
void subdomainHMaxSetup ()
 Caches the hmax for all elements in each subdomain. More...
 
RayDataIndex registerRayDataInternal (const std::string &name, const bool aux)
 Internal method for registering Ray data or Ray aux data with a name. More...
 
std::vector< RayDataIndexregisterRayDataInternal (const std::vector< std::string > &names, const bool aux)
 Internal method for registering Ray data or Ray aux data with names. More...
 
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. More...
 
std::vector< RayDataIndexgetRayDataIndicesInternal (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. More...
 
const std::string & getRayDataNameInternal (const RayDataIndex index, const bool aux) const
 Internal method for getting the name of Ray data or Ray aux data. More...
 
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 from the Ray banks. More...
 
RayID registerRay (const std::string &name)
 Registers a Ray with a given name. More...
 

Private Attributes

std::vector< libMesh::ElemSideBuilder_threaded_elem_side_builders
 Threaded helpers for building element sides without extraneous allocation. More...
 
std::unordered_map< std::string, RayDataIndex_ray_data_map
 The map from Ray data names to index. More...
 
std::unordered_map< std::string, RayDataIndex_ray_aux_data_map
 The map from Ray aux data names to index. More...
 
std::vector< std::string > _ray_data_names
 The names for each Ray data entry. More...
 
std::vector< std::string > _ray_aux_data_names
 The names for each Ray aux data entry. More...
 
std::unordered_map< std::string, RayID > & _registered_ray_map
 Map from registered Ray name to ID. More...
 
std::vector< std::string > & _reverse_registered_ray_map
 Map from registered Ray ID to name. More...
 
std::vector< TraceData_cached_traces
 Storage for the cached traces. More...
 
std::vector< std::vector< TraceData > > _threaded_cached_traces
 The threaded storage for cached traces. More...
 
std::vector< std::size_t > _num_cached
 Number of currently cached objects for Jacobian/residual for each thread. More...
 
std::set< BoundaryID_internal_sidesets
 The BoundaryIDs on the local mesh that have internal RayBCs. More...
 
std::vector< std::vector< std::vector< BoundaryID > > > _internal_sidesets_map
 Internal sideset data, if internal sidesets exist (indexed with getLocalElemIndex()) More...
 
bool _has_non_planar_sides
 Whether or not the local mesh has elements with non-planar sides. More...
 
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 here to avoid a std::vector<bool>; 0 = false, otherwise true. More...
 
bool _has_same_level_active_elems
 Whether or not the mesh has active elements of the same level. More...
 
libMesh::BoundingBox _b_box
 Nodal bounding box for the domain. More...
 
libMesh::BoundingBox _loose_b_box
 Loose nodal bounding box for the domain. More...
 
Real _domain_max_length
 An inflated max distance for the domain. More...
 
Real _total_volume
 The total volume of the domain. More...
 
std::vector< TheWarehouse::QueryCache< AttribSubdomains > > _threaded_cache_ray_kernel
 Threaded cached subdomain query for RayKernelBase objects pertaining to this study. More...
 
std::vector< TheWarehouse::QueryCache< AttribBoundaries > > _threaded_cache_ray_bc
 Threaded cached boundary query for RayBC objects pertaining to this study. More...
 
std::vector< std::vector< std::set< const RayTracingObject * > > > _threaded_ray_object_registration
 Threaded storage for all of the RayTracingObjects associated with a single Ray. More...
 
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
 The current RayKernel objects for each thread. More...
 
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
 The TraceRay objects for each thread (they do the physical tracing) More...
 
std::vector< std::unique_ptr< libMesh::FEBase > > _threaded_fe_face
 Face FE used for computing face normals for each thread. More...
 
std::vector< std::unique_ptr< libMesh::QBase > > _threaded_q_face
 Face quadrature used for computing face normals for each thread. More...
 
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. More...
 
std::vector< std::shared_ptr< Ray > > _ray_bank
 Cumulative Ray bank - stored only when _bank_rays_on_completion. More...
 
std::vector< RayID_threaded_next_ray_id
 Storage for the next available unique RayID, obtained via generateUniqueRayID() More...
 
RayID _replicated_next_ray_id
 Storage for the next available replicated RayID, obtained via generateReplicatedRayID() More...
 
const std::unique_ptr< ParallelRayStudy_parallel_ray_study
 The study that used is to actually execute (trace) the Rays. More...
 
std::unique_ptr< libMesh::QBase_segment_qrule
 Quadrature rule for laying points across a 1D ray segment. More...
 
unsigned long long int _ending_processor_crossings
 Total number of processor crossings for Rays that finished on this processor. More...
 
unsigned int _ending_max_processor_crossings
 Max number of total processor crossings for Rays that finished on this processor. More...
 
unsigned long long int _total_processor_crossings
 Total number of processor crossings. More...
 
unsigned int _max_processor_crossings
 Max number of processor crossings for all Rays. More...
 
unsigned long long int _ending_intersections
 Total number of Ray/element intersections for Rays that finished on this processor. More...
 
unsigned int _ending_max_intersections
 Max number of intersections for Rays that finished on this processor. More...
 
unsigned int _ending_max_trajectory_changes
 Max number of trajectory changes for Rays that finished on this processor. More...
 
unsigned long long int _total_intersections
 Total number of Ray/element intersections. More...
 
unsigned int _max_intersections
 Max number of intersections for a single Ray. More...
 
unsigned int _max_trajectory_changes
 Max number of trajectory changes for a single Ray. More...
 
Real _ending_distance
 Total distance traveled by Rays that end on this processor. More...
 
Real _total_distance
 Total distance traveled by all Rays. More...
 
std::vector< unsigned long long int_local_trace_ray_results
 Cumulative results on this processor from the threaded TraceRay objects. More...
 
std::unordered_map< SubdomainID, Real_subdomain_hmax
 The cached hmax for all elements in a subdomain. More...
 
bool _called_initial_setup
 Whether or not we've called initial setup - used to stop from late registration. More...
 
ElemIndexHelper _elem_index_helper
 Helper for defining a local contiguous index for each element. More...
 
Threads::spin_mutex _spin_mutex
 Spin mutex object for locks. More...
 
std::chrono::steady_clock::time_point _execution_start_time
 Timing. More...
 
std::chrono::steady_clock::duration _execution_time
 
std::chrono::steady_clock::duration _generation_time
 
std::chrono::steady_clock::duration _propagation_time
 

Detailed Description

Base class for Ray tracing studies that will generate Rays and then propagate all of them to termination.

Subclasses must override generateRays()

Definition at line 40 of file RayTracingStudy.h.

Constructor & Destructor Documentation

◆ RayTracingStudy()

RayTracingStudy::RayTracingStudy ( const InputParameters parameters)

Definition at line 130 of file RayTracingStudy.C.

133  _comm(_mesh.comm()),
134  _pid(_comm.rank()),
135 
136  _ray_kernel_coverage_check(getParam<bool>("ray_kernel_coverage_check")),
137  _warn_non_planar(getParam<bool>("warn_non_planar")),
138  _use_ray_registration(getParam<bool>("_use_ray_registration")),
139  _use_internal_sidesets(getParam<bool>("use_internal_sidesets")),
140  _tolerate_failure(getParam<bool>("tolerate_failure")),
141  _bank_rays_on_completion(getParam<bool>("_bank_rays_on_completion")),
142  _ray_dependent_subdomain_setup(getParam<bool>("_ray_dependent_subdomain_setup")),
143 
144  _always_cache_traces(getParam<bool>("always_cache_traces")),
145  _data_on_cache_traces(getParam<bool>("data_on_cache_traces")),
146  _aux_data_on_cache_traces(getParam<bool>("aux_data_on_cache_traces")),
147  _segments_on_cache_traces(getParam<bool>("segments_on_cache_traces")),
148  _ray_max_distance(getParam<Real>("ray_distance")),
149  _verify_rays(getParam<bool>("verify_rays")),
150 #ifndef NDEBUG
151  _verify_trace_intersections(getParam<bool>("verify_trace_intersections")),
152 #endif
153 
155 
157  declareRestartableData<std::unordered_map<std::string, RayID>>("registered_ray_map")),
159  declareRestartableData<std::vector<std::string>>("reverse_registered_ray_map")),
160 
162 
164 
165  _has_non_planar_sides(true),
167 
168  _b_box(MeshTools::create_nodal_bounding_box(_mesh.getMesh())),
169  _domain_max_length(1.01 * (_b_box.max() - _b_box.min()).norm()),
171 
181 
182  _parallel_ray_study(std::make_unique<ParallelRayStudy>(*this, _threaded_trace_ray)),
183 
185 
186  _called_initial_setup(false),
187 
188  _elem_index_helper(_mesh.getMesh(), name() + "_elem_index")
189 {
190  // Initialize a tracing object for each thread
191  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
192  {
193  // Initialize a tracing object for each thread
194  _threaded_trace_ray[tid] = std::make_shared<TraceRay>(*this, tid);
195 
196  // Setup the face FEs for normal computation on the fly
197  _threaded_fe_face[tid] = FEBase::build(_mesh.dimension(), FEType(CONSTANT, MONOMIAL));
198  _threaded_q_face[tid] = QBase::build(QGAUSS, _mesh.dimension() - 1, CONSTANT);
199  _threaded_fe_face[tid]->attach_quadrature_rule(_threaded_q_face[tid].get());
200  _threaded_fe_face[tid]->get_normals();
201  }
202 
203  // Evaluating on residual and Jacobian evaluation
204  if (_execute_enum.isValueSet(EXEC_PRE_KERNELS))
205  {
206  if (!getParam<bool>("allow_other_flags_with_prekernels") && _execute_enum.size() > 1)
207  paramError("execute_on",
208  "PRE_KERNELS cannot be mixed with any other execution flag.\nThat is, you cannot "
209  "currently "
210  "mix RayKernels that contribute to the Jacobian/residual with those that do not.");
211 
212  if (_app.useEigenvalue())
213  mooseError("Execution on residual and Jacobian evaluation (execute_on = PRE_KERNELS)\n",
214  "is not supported for an eigenvalue solve.");
215  }
216 
219 
220  // Scale the bounding box for loose checking
222  _loose_b_box.scale(TOLERANCE * TOLERANCE);
223 }
const bool _tolerate_failure
Whether or not to tolerate a Ray Tracing failure.
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
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 n_threads()
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...
const bool _segments_on_cache_traces
Whether or not to cache individual element segments when caching.
MooseMesh & _mesh
The Mesh.
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.
const Real _ray_max_distance
Max distance a Ray can travel before being killed (can change)
libMesh::BoundingBox _loose_b_box
Loose nodal bounding box for the domain.
unsigned int size() const
processor_id_type rank() const
const Parallel::Communicator & comm() const
const bool _verify_trace_intersections
Whether or not to verify the trace intersections in devel and dbg modes.
T & declareRestartableData(const std::string &data_name, Args &&... args)
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::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)
std::vector< RayID > _threaded_next_ray_id
Storage for the next available unique RayID, obtained via generateUniqueRayID()
const bool _ray_dependent_subdomain_setup
Whether or not subdomain setup is dependent on the Ray.
CONSTANT
bool & useEigenvalue()
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.
MeshBase & getMesh()
const bool _bank_rays_on_completion
Whether or not to bank rays on completion.
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.
virtual unsigned int dimension() const
const Point & min() const
std::vector< TheWarehouse::QueryCache< AttribSubdomains > > _threaded_cache_ray_kernel
Threaded cached subdomain query for RayKernelBase objects pertaining to this study.
std::vector< std::unique_ptr< libMesh::FEBase > > _threaded_fe_face
Face FE used for computing face normals for each thread.
std::vector< TheWarehouse::QueryCache< AttribBoundaries > > _threaded_cache_ray_bc
Threaded cached boundary query for RayBC objects pertaining to this study.
void paramError(const std::string &param, Args... args) const
bool isValueSet(const std::string &value) const
auto norm(const T &a) -> decltype(std::abs(a))
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 ExecFlagEnum & _execute_enum
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
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.
Real _total_volume
The total volume of the domain.
const bool _aux_data_on_cache_traces
Whether or not to store the Ray aux data on the cache traces.
bool _has_non_planar_sides
Whether or not the local mesh has elements with non-planar sides.
const bool _verify_rays
Whether or not to verify if Rays have valid information before being traced.
FEProblemBase & _fe_problem
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
virtual MooseMesh & mesh() override
GeneralUserObject(const InputParameters &parameters)
void mooseError(Args &&... args) const
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.
const Parallel::Communicator & _comm
The Communicator.
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.
const Point & max() const
std::vector< unsigned long long int > _local_trace_ray_results
Cumulative results on this processor from the threaded TraceRay objects.
void scale(const Real factor)
std::vector< libMesh::ElemSideBuilder > _threaded_elem_side_builders
Threaded helpers for building element sides without extraneous allocation.
void resetUniqueRayIDs()
Resets the generation of unique RayIDs via generateUniqueRayID() to the beginning of the range...
std::vector< std::unique_ptr< libMesh::QBase > > _threaded_q_face
Face quadrature used for computing face normals for each thread.
unsigned int THREAD_ID
Real computeTotalVolume()
Helper function for computing the total domain volume.

Member Function Documentation

◆ acquireCopiedRay()

std::shared_ptr< Ray > RayTracingStudy::acquireCopiedRay ( const Ray ray)
protected

Acquires a Ray that that is copied from another Ray within generateRays().

All of the information is copied except for the counters (intersections, processor crossings, etc), which are reset.

Definition at line 1731 of file RayTracingStudy.C.

Referenced by RepeatableRayStudyBaseTest::defineRays(), RayTracingStudyTest::generateRays(), and RepeatableRayStudyBase::generateRays().

1732 {
1733  mooseAssert(currentlyGenerating(), "Can only use during generateRays()");
1734  return _parallel_ray_study->acquireParallelData(
1735  /* tid = */ 0, &ray, Ray::ConstructRayKey());
1736 }
bool currentlyGenerating() const
Whether or not the study is generating.
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ acquireRay()

std::shared_ptr< Ray > RayTracingStudy::acquireRay ( )
protected

User APIs for constructing Rays within the RayTracingStudy.

Rays can ONLY be constructed by users within the RayTracingStudy via the following methods. Acquire a Ray from the pool of Rays within generateRays().

A unique ID is generated and assigned to the acquired Ray. The data and aux data sizes are set according to the sizes required by the RayTracingStudy.

Definition at line 1667 of file RayTracingStudy.C.

Referenced by LotsOfRaysRayStudy::defineRay(), StationaryRayStudyTest::generateRays(), TestRay::generateRays(), RayTracingStudyTest::generateRays(), TestReuseRaysStudy::generateRays(), TestTransientRaysStudy::generateRays(), and ViewFactorRayStudy::generateRays().

1668 {
1669  mooseAssert(currentlyGenerating(), "Can only use during generateRays()");
1670 
1671  return _parallel_ray_study->acquireParallelData(
1672  /* tid = */ 0,
1673  this,
1674  generateUniqueRayID(/* tid = */ 0),
1675  rayDataSize(),
1676  rayAuxDataSize(),
1677  /* reset = */ true,
1679 }
bool currentlyGenerating() const
Whether or not the study is generating.
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
virtual RayID generateUniqueRayID(const THREAD_ID tid)
Generates a unique RayID to be used for a Ray.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
std::size_t rayDataSize() const
The registered size of values in the Ray data.

◆ acquireRayDuringTrace()

std::shared_ptr< Ray > RayTracingStudy::acquireRayDuringTrace ( const THREAD_ID  tid,
const AcquireMoveDuringTraceKey  
)

INTERNAL methods for acquiring a Ray during a trace in RayKernels and RayBCs.

You should not use these APIs directly. If you wish to acquire a Ray during generation during generateRays()), use the protected RayTracingStudy::acquire{}Ray() methods. If you wish to acquire a Ray during propagation in RayKernels and RayBC, use the protected RayKernelBase::acquireRay() and RayBoundaryConditionBase::acquireRay(), respectively.

Definition at line 1739 of file RayTracingStudy.C.

Referenced by RayBoundaryConditionBase::acquireRay(), and RayKernelBase::acquireRay().

1740 {
1741  mooseAssert(currentlyPropagating(), "Can only use during propagation");
1742  return _parallel_ray_study->acquireParallelData(tid,
1743  this,
1744  generateUniqueRayID(tid),
1745  rayDataSize(),
1746  rayAuxDataSize(),
1747  /* reset = */ true,
1749 }
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
virtual RayID generateUniqueRayID(const THREAD_ID tid)
Generates a unique RayID to be used for a Ray.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
std::size_t rayDataSize() const
The registered size of values in the Ray data.

◆ acquireRayInternal()

std::shared_ptr<Ray> RayTracingStudy::acquireRayInternal ( const RayID  id,
const std::size_t  data_size,
const std::size_t  aux_data_size,
const bool  reset,
const AcquireRayInternalKey  
)
inline

Definition at line 489 of file RayTracingStudy.h.

Referenced by dataLoad(), and libMesh::Parallel::Packing< std::shared_ptr< Ray > >::unpack().

494  {
495  return _parallel_ray_study->acquireParallelData(
496  0, this, id, data_size, aux_data_size, reset, Ray::ConstructRayKey());
497  }
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ acquireRegisteredRay()

std::shared_ptr< Ray > RayTracingStudy::acquireRegisteredRay ( const std::string &  name)
protected

Acquires a Ray with a given name within generateRays().

Used when ray registration is enabled, that is, the private paramater '_use_ray_registration' == true.

This method must be called on all processors at the same time with the same name. This method can only be called on thread 0, which is why there is no thread argument.

Definition at line 1712 of file RayTracingStudy.C.

Referenced by RepeatableRayStudyBaseTest::defineRays(), RepeatableRayStudy::defineRays(), and RayTracingStudyTest::generateRays().

1713 {
1714  mooseAssert(currentlyGenerating(), "Can only use during generateRays()");
1715 
1716  // Either register a Ray or get an already registered Ray id
1717  const RayID id = registerRay(name);
1718 
1719  // Acquire a Ray with the properly sized data initialized to zero
1720  return _parallel_ray_study->acquireParallelData(
1721  /* tid = */ 0,
1722  this,
1723  id,
1724  rayDataSize(),
1725  rayAuxDataSize(),
1726  /* reset = */ true,
1728 }
bool currentlyGenerating() const
Whether or not the study is generating.
RayID registerRay(const std::string &name)
Registers a Ray with a given name.
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
virtual const std::string & name() const
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
std::size_t rayDataSize() const
The registered size of values in the Ray data.

◆ acquireReplicatedRay()

std::shared_ptr< Ray > RayTracingStudy::acquireReplicatedRay ( )
protected

Acquire a Ray from the pool of Rays within generateRays() in a replicated fashion.

That is, this method must be called on all processors at the same time and the ID of the resulting Ray is the same across all processors.

The data and aux data sizes are set according to the sizes required by the RayTracingStudy.

Definition at line 1696 of file RayTracingStudy.C.

Referenced by ConeRayStudy::defineRays(), and TestPICRayStudy::generateRays().

1697 {
1698  mooseAssert(currentlyGenerating(), "Can only use during generateRays()");
1699  libmesh_parallel_only(comm());
1700 
1701  return _parallel_ray_study->acquireParallelData(
1702  /* tid = */ 0,
1703  this,
1705  rayDataSize(),
1706  rayAuxDataSize(),
1707  /* reset = */ true,
1709 }
bool currentlyGenerating() const
Whether or not the study is generating.
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
const Parallel::Communicator & comm() const
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
RayID generateReplicatedRayID()
Generates a Ray ID that is replicated across all processors.
std::size_t rayDataSize() const
The registered size of values in the Ray data.

◆ acquireUnsizedRay()

std::shared_ptr< Ray > RayTracingStudy::acquireUnsizedRay ( )
protected

Acquire a Ray from the pool of Rays within generateRays(), without resizing the data (sizes the data to zero).

A unique ID is generated and assigned to the acquired Ray.

Definition at line 1682 of file RayTracingStudy.C.

Referenced by LotsOfRaysRayStudy::defineRay().

1683 {
1684  mooseAssert(currentlyGenerating(), "Can only use during generateRays()");
1685 
1686  return _parallel_ray_study->acquireParallelData(/* tid = */ 0,
1687  this,
1688  generateUniqueRayID(/* tid = */ 0),
1689  /* data_size = */ 0,
1690  /* aux_data_size = */ 0,
1691  /* reset = */ true,
1693 }
bool currentlyGenerating() const
Whether or not the study is generating.
Class that is used as a parameter to the public constructors/reset methods.
Definition: Ray.h:87
virtual RayID generateUniqueRayID(const THREAD_ID tid)
Generates a unique RayID to be used for a Ray.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ auxDataOnCacheTraces()

bool RayTracingStudy::auxDataOnCacheTraces ( ) const
inline

Whether or not to store the Ray aux data on the cached Ray traces.

Definition at line 573 of file RayTracingStudy.h.

Referenced by TraceRay::continueTraceOffProcessor(), TraceRay::onCompleteTrace(), TraceRay::onContinueTrace(), TraceRay::onTrajectoryChanged(), RayTracingMeshOutput::RayTracingMeshOutput(), and TraceRay::trace().

573 { return _aux_data_on_cache_traces; }
const bool _aux_data_on_cache_traces
Whether or not to store the Ray aux data on the cache traces.

◆ bankRaysOnCompletion()

bool RayTracingStudy::bankRaysOnCompletion ( ) const
inline

Whether or not to bank Rays on completion.

Definition at line 214 of file RayTracingStudy.h.

Referenced by RayIntegralValue::initialize(), and RayDataValue::RayDataValue().

214 { return _bank_rays_on_completion; }
const bool _bank_rays_on_completion
Whether or not to bank rays on completion.

◆ boundingBox()

const BoundingBox& RayTracingStudy::boundingBox ( ) const
inline

Get the nodal bounding box for the domain.

Definition at line 422 of file RayTracingStudy.h.

Referenced by TestRayDataStudy::auxDataValue(), TestRayDataStudy::dataValue(), LotsOfRaysRayStudy::defineRays(), and TraceRay::trace().

422 { return _b_box; }
libMesh::BoundingBox _b_box
Nodal bounding box for the domain.

◆ buildSegmentQuadrature()

void RayTracingStudy::buildSegmentQuadrature ( const Point start,
const Point end,
const Real  length,
std::vector< Point > &  points,
std::vector< Real > &  weights 
) const
protectedvirtual

Builds quadrature points for a given segment using the _segment_qrule.

Parameters
startStart point of the segment
endEnd point of the segment
lengthThe lengh of the start -> end segment
pointsPoints to fill into (should be sized ahead of time)
weightsWeights to fill into (should be sized ahead of time)

Definition at line 710 of file RayTracingStudy.C.

Referenced by reinitSegment().

715 {
716  points.resize(_segment_qrule->n_points());
717  weights.resize(_segment_qrule->n_points());
718 
719  const Point diff = end - start;
720  const Point sum = end + start;
721  mooseAssert(MooseUtils::absoluteFuzzyEqual(length, diff.norm()), "Invalid length");
722 
723  // The standard quadrature rule should be on x = [-1, 1]
724  // To scale the points, you...
725  // - Scale to size of the segment in 3D
726  // initial_scaled_qp = x_qp * 0.5 * (end - start) = 0.5 * x_qp * diff
727  // - Shift quadrature midpoint to segment midpoint
728  // final_qp = initial_scaled_qp + 0.5 * (end - start) = initial_scaled_qp + 0.5 * sum
729  // = 0.5 * (x_qp * diff + sum)
730  for (unsigned int qp = 0; qp < _segment_qrule->n_points(); ++qp)
731  {
732  points[qp] = 0.5 * (_segment_qrule->qp(qp)(0) * diff + sum);
733  weights[qp] = 0.5 * _segment_qrule->w(qp) * length;
734  }
735 }
auto norm() const -> decltype(std::norm(Real()))
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
std::unique_ptr< libMesh::QBase > _segment_qrule
Quadrature rule for laying points across a 1D ray segment.

◆ computeTotalVolume()

Real RayTracingStudy::computeTotalVolume ( )
protected

Helper function for computing the total domain volume.

Definition at line 1387 of file RayTracingStudy.C.

1388 {
1389  Real volume = 0;
1390  for (const auto & elem : *_mesh.getActiveLocalElementRange())
1391  volume += elem->volume();
1392  _communicator.sum(volume);
1393  return volume;
1394 }
libMesh::ConstElemRange * getActiveLocalElementRange()
MooseMesh & _mesh
The Mesh.
const Parallel::Communicator & _communicator
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ coverageChecks()

void RayTracingStudy::coverageChecks ( )
private

Perform coverage checks (coverage of RayMaterials and RayKernels, if enabled)

Definition at line 316 of file RayTracingStudy.C.

Referenced by initialSetup().

317 {
318  // Check for coverage of RayKernels on domain
320  {
321  std::vector<RayKernelBase *> ray_kernels;
322  getRayKernels(ray_kernels, 0);
323 
324  std::set<SubdomainID> ray_kernel_blocks;
325  for (const auto & rk : ray_kernels)
326  ray_kernel_blocks.insert(rk->blockIDs().begin(), rk->blockIDs().end());
327 
328  std::set<SubdomainID> missing;
329  std::set_difference(_mesh.meshSubdomains().begin(),
330  _mesh.meshSubdomains().end(),
331  ray_kernel_blocks.begin(),
332  ray_kernel_blocks.end(),
333  std::inserter(missing, missing.begin()));
334 
335  if (!missing.empty() && !ray_kernel_blocks.count(Moose::ANY_BLOCK_ID))
336  {
337  std::ostringstream error;
338  error << "Subdomains { ";
339  std::copy(missing.begin(), missing.end(), std::ostream_iterator<SubdomainID>(error, " "));
340  error << "} do not have RayKernels defined!";
341 
342  mooseError(error.str());
343  }
344  }
345 }
void getRayKernels(std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.
MooseMesh & _mesh
The Mesh.
const SubdomainID ANY_BLOCK_ID
void mooseError(Args &&... args) const
const bool _ray_kernel_coverage_check
Whether or not to perform coverage checks on RayKernels.
const std::set< SubdomainID > & meshSubdomains() const

◆ currentlyGenerating()

bool RayTracingStudy::currentlyGenerating ( ) const
inline

Whether or not the study is generating.

Definition at line 641 of file RayTracingStudy.h.

Referenced by acquireCopiedRay(), acquireRay(), acquireRegisteredRay(), acquireReplicatedRay(), acquireUnsizedRay(), dataLoad(), moveRaysToBuffer(), moveRayToBuffer(), rayBank(), reserveRayBuffer(), Ray::resetCounters(), resetReplicatedRayIDs(), and resetUniqueRayIDs().

641 { return _parallel_ray_study->currentlyPreExecuting(); }
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ currentlyPropagating()

bool RayTracingStudy::currentlyPropagating ( ) const
inline

◆ currentRayKernels()

const std::vector<RayKernelBase *>& RayTracingStudy::currentRayKernels ( THREAD_ID  tid) const
inline

Gets the current RayKernels for a thread, which are set in segmentSubdomainSetup()

Definition at line 414 of file RayTracingStudy.h.

Referenced by TraceRay::onCompleteTrace(), TraceRay::onSegment(), TraceRay::onSubdomainChanged(), reinitSegment(), and TraceRay::trace().

415  {
416  return _threaded_current_ray_kernels[tid];
417  }
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.

◆ currentRayKernelsWrite()

std::vector<RayKernelBase *>& RayTracingStudy::currentRayKernelsWrite ( THREAD_ID  tid)
inlineprotected

Gets the writeable current RayKernels for a thread.

Allows for other ray studies to fill the current ray kernels in a custom manner

Definition at line 721 of file RayTracingStudy.h.

722  {
723  return _threaded_current_ray_kernels[tid];
724  }
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.

◆ dataOnCacheTraces()

bool RayTracingStudy::dataOnCacheTraces ( ) const
inline

Whether or not to store the Ray data on the cached Ray traces.

Definition at line 569 of file RayTracingStudy.h.

Referenced by TraceRay::continueTraceOffProcessor(), TraceRay::onCompleteTrace(), TraceRay::onContinueTrace(), TraceRay::onTrajectoryChanged(), RayTracingMeshOutput::RayTracingMeshOutput(), and TraceRay::trace().

569 { return _data_on_cache_traces; }
const bool _data_on_cache_traces
Whether or not to store the Ray data on the cache traces.

◆ dependencyChecks()

void RayTracingStudy::dependencyChecks ( )
private

Perform checks to see if the listed dependencies in the RayTracingObjects exist.

Definition at line 348 of file RayTracingStudy.C.

Referenced by initialSetup().

349 {
350  std::vector<RayTracingObject *> ray_tracing_objects;
351 
352  getRayKernels(ray_tracing_objects, 0);
353  verifyDependenciesExist(ray_tracing_objects);
354 
355  getRayBCs(ray_tracing_objects, 0);
356  verifyDependenciesExist(ray_tracing_objects);
357 }
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 verifyDependenciesExist(const std::vector< RayTracingObject *> &rtos)
Verifies that the dependencies exist for a set of RayTracingObjects.
void getRayBCs(std::vector< RayBoundaryConditionBase *> &result, BoundaryID id, THREAD_ID tid)
Fills the active RayBCs associated with this study and a boundary into result.

◆ domainMaxLength()

Real RayTracingStudy::domainMaxLength ( ) const
inline

Get the inflated maximum length across the domain.

Definition at line 433 of file RayTracingStudy.h.

Referenced by TraceRay::exitsElem(), and TraceRay::trace().

433 { return _domain_max_length; }
Real _domain_max_length
An inflated max distance for the domain.

◆ elemSide()

const libMesh::Elem& RayTracingStudy::elemSide ( const libMesh::Elem elem,
const unsigned int  s,
const THREAD_ID  tid = 0 
)
inline

Get an element's side pointer without excessive memory allocation.

Parameters
elemThe element to build a side for
sThe side to build
tidThe thread id
Returns
A pointer to the side element

Definition at line 689 of file RayTracingStudy.h.

Referenced by LotsOfRaysRayStudy::defineRays(), StationaryRayStudyTest::generateRays(), nonPlanarSideSetup(), and ClaimRays::postClaimRay().

690  {
691  return _threaded_elem_side_builders[tid](elem, s);
692  }
std::vector< libMesh::ElemSideBuilder > _threaded_elem_side_builders
Threaded helpers for building element sides without extraneous allocation.

◆ endingDistance()

Real RayTracingStudy::endingDistance ( ) const
inline

Total amount of distance traveled by the rays that end on this processor.

Definition at line 168 of file RayTracingStudy.h.

168 { return _ending_distance; }
Real _ending_distance
Total distance traveled by Rays that end on this processor.

◆ endingIntersections()

unsigned long long int RayTracingStudy::endingIntersections ( ) const
inline

Total number of Ray/element intersections for Rays that finished on this processor.

Definition at line 147 of file RayTracingStudy.h.

147 { return _ending_intersections; }
unsigned long long int _ending_intersections
Total number of Ray/element intersections for Rays that finished on this processor.

◆ endingMaxIntersections()

unsigned int RayTracingStudy::endingMaxIntersections ( ) const
inline

Max number of intersections for Rays that finished on this processor.

Definition at line 151 of file RayTracingStudy.h.

151 { return _ending_max_intersections; }
unsigned int _ending_max_intersections
Max number of intersections for Rays that finished on this processor.

◆ endingMaxProcessorCrossings()

unsigned int RayTracingStudy::endingMaxProcessorCrossings ( ) const
inline

Max number of total processor crossings for Rays that finished on this processor.

Definition at line 134 of file RayTracingStudy.h.

unsigned int _ending_max_processor_crossings
Max number of total processor crossings for Rays that finished on this processor. ...

◆ endingProcessorCrossings()

unsigned long long int RayTracingStudy::endingProcessorCrossings ( ) const
inline

Total number of processor crossings for Rays that finished on this processor.

Definition at line 130 of file RayTracingStudy.h.

130 { return _ending_processor_crossings; }
unsigned long long int _ending_processor_crossings
Total number of processor crossings for Rays that finished on this processor.

◆ execute()

void RayTracingStudy::execute ( )
overridevirtual

Executes the study (generates and propagates Rays)

Implements GeneralUserObject.

Reimplemented in SingleTraceLineSourceTest.

Definition at line 310 of file RayTracingStudy.C.

Referenced by SingleTraceLineSourceTest::execute().

311 {
312  executeStudy();
313 }
void executeStudy()
Method for executing the study so that it can be called out of the standard UO execute() ...

◆ executeStudy()

void RayTracingStudy::executeStudy ( )

Method for executing the study so that it can be called out of the standard UO execute()

Definition at line 771 of file RayTracingStudy.C.

Referenced by execute().

772 {
773  TIME_SECTION("executeStudy", 2, "Executing Study");
774 
775  mooseAssert(_called_initial_setup, "Initial setup not called");
776 
777  // Reset ray start/complete timers
779  _max_intersections = 0;
781 
782  // Reset physical tracing stats
783  for (auto & val : _local_trace_ray_results)
784  val = 0;
785 
786  // Reset crossing and intersection
793  _ending_distance = 0;
794  _total_distance = 0;
795 
796  // Zero the AuxVariables that our AuxRayKernels contribute to before they accumulate
798 
799  preExecuteStudy();
800  for (auto & rto : getRayTracingObjects())
801  rto->preExecuteStudy();
802 
803  _ray_bank.clear();
804 
805  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
806  {
807  _threaded_trace_ray[tid]->preExecute();
808  _threaded_cached_normals[tid].clear();
809  }
810 
812  _execution_start_time = std::chrono::steady_clock::now();
813 
814  _parallel_ray_study->preExecute();
815 
816  {
817  {
818  auto generation_start_time = std::chrono::steady_clock::now();
819 
820  TIME_SECTION("generateRays", 2, "Generating Rays");
821 
822  generateRays();
823 
824  _generation_time = std::chrono::steady_clock::now() - generation_start_time;
825  }
826 
827  // At this point, nobody is working so this is good time to make sure
828  // Rays are unique across all processors in the working buffer
829  if (verifyRays())
830  {
831  verifyUniqueRays(_parallel_ray_study->workBuffer().begin(),
832  _parallel_ray_study->workBuffer().end(),
833  /* error_suffix = */ "after generateRays()");
834 
835  verifyUniqueRayIDs(_parallel_ray_study->workBuffer().begin(),
836  _parallel_ray_study->workBuffer().end(),
837  /* global = */ true,
838  /* error_suffix = */ "after generateRays()");
839  }
840 
842 
843  {
844  TIME_SECTION("propagateRays", 2, "Propagating Rays");
845 
846  const auto propagation_start_time = std::chrono::steady_clock::now();
847 
848  _parallel_ray_study->execute();
849 
850  _propagation_time = std::chrono::steady_clock::now() - propagation_start_time;
851  }
852  }
853 
854  _execution_time = std::chrono::steady_clock::now() - _execution_start_time;
855 
856  if (verifyRays())
857  {
858  verifyUniqueRays(_parallel_ray_study->workBuffer().begin(),
859  _parallel_ray_study->workBuffer().end(),
860  /* error_suffix = */ "after tracing completed");
861 
862 #ifndef NDEBUG
863  // Outside of debug, _ray_bank always holds all of the Rays that have ended on this processor
864  // We can use this as a global point to check for unique IDs for every Ray that has traced
866  _ray_bank.end(),
867  /* global = */ true,
868  /* error_suffix = */ "after tracing completed");
869 #endif
870  }
871 
872  // Update counters from the threaded trace objects
873  for (const auto & tr : _threaded_trace_ray)
874  for (std::size_t i = 0; i < _local_trace_ray_results.size(); ++i)
875  _local_trace_ray_results[i] += tr->results()[i];
876 
877  // Update local ending counters
884  // ...and communicate the global values
891 
892  // Throw a warning with the number of failed (tolerated) traces
893  if (_tolerate_failure)
894  {
896  _communicator.sum(failures);
897  if (failures)
898  mooseWarning(
899  type(), " '", name(), "': ", failures, " ray tracing failures were tolerated.\n");
900  }
901 
902  // Clear the current RayKernels
903  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
905 
906  // Move the threaded cache trace information into the full cached trace vector
907  // Here, we only clear the cached vectors so that we might not have to
908  // reallocate on future traces
909  std::size_t num_entries = 0;
910  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
911  num_entries += _threaded_cached_traces[tid].size();
912  _cached_traces.clear();
913  _cached_traces.reserve(num_entries);
914  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
915  {
916  for (const auto & entry : _threaded_cached_traces[tid])
917  _cached_traces.emplace_back(std::move(entry));
918  _threaded_cached_traces[tid].clear();
919  }
920 
921  // Add any stragglers that contribute to the Jacobian or residual
922  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
923  if (_num_cached[tid] != 0)
924  {
925  mooseAssert(_fe_problem.currentlyComputingJacobian() ||
927  "Should not have cached values without Jacobian/residual computation");
928 
931  else
933 
934  _num_cached[tid] = 0;
935  }
936 
937  // AuxRayKernels may have modified AuxVariables
940 
941  // Clear FE
942  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
943  {
946  }
947 
949  for (auto & rto : getRayTracingObjects())
950  rto->postExecuteStudy();
951 }
const bool _tolerate_failure
Whether or not to tolerate a Ray Tracing failure.
unsigned long long int _total_intersections
Total number of Ray/element intersections.
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.
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.
unsigned int n_threads()
NumericVector< Number > & solution()
std::vector< std::vector< TraceData > > _threaded_cached_traces
The threaded storage for cached traces.
Real _ending_distance
Total distance traveled by Rays that end on this processor.
const Parallel::Communicator & _communicator
void clearActiveMaterialProperties(const THREAD_ID tid)
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.
virtual const std::string & name() const
void mooseWarning(Args &&... args) const
std::vector< TraceData > _cached_traces
Storage for the cached traces.
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)
unsigned long long int _total_processor_crossings
Total number of processor crossings.
bool verifyRays() const
Whether or not to verify if Rays have valid information before being traced.
unsigned int _ending_max_intersections
Max number of intersections for Rays that finished on this processor.
sideset clear()
virtual void postExecuteStudy()
Entry point after study execution.
unsigned int _max_processor_crossings
Max number of processor crossings for all Rays.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
const bool & currentlyComputingResidual() const
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. ...
void zeroAuxVariables()
Zero the AuxVariables that the registered AuxRayKernels contribute to.
const std::string & type() const
std::chrono::steady_clock::time_point _execution_start_time
Timing.
virtual void preExecuteStudy()
Entry point before study execution.
AuxiliarySystem & getAuxiliarySystem()
virtual void generateRays()=0
Subclasses should override this to determine how to generate Rays.
virtual void close()=0
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.
void max(const T &r, T &o, Request &req) const
FEProblemBase & _fe_problem
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
std::chrono::steady_clock::duration _propagation_time
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
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.
Real _total_distance
Total distance traveled by all Rays.
const bool & currentlyComputingJacobian() const
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.
virtual void addCachedResidual(const THREAD_ID tid) override
std::chrono::steady_clock::duration _execution_time
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
unsigned int THREAD_ID
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ executionTime()

Real RayTracingStudy::executionTime ( )
inline

Duration for execute() in seconds.

Definition at line 189 of file RayTracingStudy.h.

189 { return std::chrono::duration<Real>(_execution_time).count(); }
std::chrono::steady_clock::duration _execution_time

◆ executionTimeNano()

Real RayTracingStudy::executionTimeNano ( )
inline

Duration for execute() in nanoseconds.

Definition at line 193 of file RayTracingStudy.h.

194  {
195  return std::chrono::duration<Real, std::nano>(_execution_time).count();
196  }
std::chrono::steady_clock::duration _execution_time

◆ finalize()

virtual void RayTracingStudy::finalize ( )
inlineoverridevirtual

Implements GeneralUserObject.

Definition at line 81 of file RayTracingStudy.h.

81 {}

◆ generateRays()

virtual void RayTracingStudy::generateRays ( )
protectedpure virtual

Subclasses should override this to determine how to generate Rays.

This will be called within execute() and makes up the "generation phase" of the algorithm.

Implemented in ViewFactorRayStudy, RayTracingStudyWithRegistrationTest, RayTracingStudyNoBankingTest, RepeatableRayStudyBase, TestTransientRaysStudy, TestReuseRaysStudy, TestPICRayStudy, RayTracingStudyTest, StationaryRayStudyTest, and TestRay.

Referenced by executeStudy().

◆ generateReplicatedRayID()

RayID RayTracingStudy::generateReplicatedRayID ( )
protected

Generates a Ray ID that is replicated across all processors.

Definition at line 1650 of file RayTracingStudy.C.

Referenced by acquireReplicatedRay().

1651 {
1652  return _replicated_next_ray_id++;
1653 }
RayID _replicated_next_ray_id
Storage for the next available replicated RayID, obtained via generateReplicatedRayID() ...

◆ generateUniqueRayID()

RayID RayTracingStudy::generateUniqueRayID ( const THREAD_ID  tid)
protectedvirtual

Generates a unique RayID to be used for a Ray.

This is used internally when acquiring new Rays.

Definition at line 1625 of file RayTracingStudy.C.

Referenced by acquireRay(), acquireRayDuringTrace(), and acquireUnsizedRay().

1626 {
1627  // Get the current ID to return
1628  const auto id = _threaded_next_ray_id[tid];
1629 
1630  // Advance so that the next call has the correct ID
1632 
1633  return id;
1634 }
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
unsigned int n_threads()
std::vector< RayID > _threaded_next_ray_id
Storage for the next available unique RayID, obtained via generateUniqueRayID()
processor_id_type n_processors() const

◆ generationTime()

Real RayTracingStudy::generationTime ( ) const
inline

Duration for creation of all Rays in seconds.

Definition at line 200 of file RayTracingStudy.h.

Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().

200 { return std::chrono::duration<Real>(_generation_time).count(); }
std::chrono::steady_clock::duration _generation_time

◆ getBankedRay()

std::shared_ptr< Ray > RayTracingStudy::getBankedRay ( const RayID  ray_id) const
protected

Gets the Ray with the ID ray_id from the Ray bank.

If the Ray with ray_id is not found across all processors, this will error.

This will ONLY return a valid Ray (not a null shared_ptr) on the processor that has the Ray.

Definition at line 1277 of file RayTracingStudy.C.

Referenced by getBankedRayDataInternal().

1278 {
1279  // This is only a linear search - can be improved on with a map in the future
1280  // if this is used on a larger scale
1281  std::shared_ptr<Ray> ray;
1282  for (const std::shared_ptr<Ray> & possible_ray : rayBank())
1283  if (possible_ray->id() == ray_id)
1284  {
1285  ray = possible_ray;
1286  break;
1287  }
1288 
1289  // Make sure one and only one processor has the Ray
1290  unsigned int have_ray = ray ? 1 : 0;
1291  _communicator.sum(have_ray);
1292  if (have_ray == 0)
1293  mooseError("Could not find a Ray with the ID ", ray_id, " in the Ray banks.");
1294 
1295  // This should never happen... but let's make sure
1296  mooseAssert(have_ray == 1, "Multiple rays with the same ID were found in the Ray banks");
1297 
1298  return ray;
1299 }
const std::vector< std::shared_ptr< Ray > > & rayBank() const
Get the Ray bank.
const Parallel::Communicator & _communicator
void mooseError(Args &&... args) const

◆ getBankedRayAuxData()

RayData RayTracingStudy::getBankedRayAuxData ( const RayID  ray_id,
const RayDataIndex  index 
) const

Gets the data value for a banked ray with a given ID.

This will return the value replicated across all processors

Definition at line 1321 of file RayTracingStudy.C.

Referenced by RayDataValue::getValue().

1322 {
1323  return getBankedRayDataInternal(ray_id, index, /* aux = */ true);
1324 }
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 ...

◆ getBankedRayData()

RayData RayTracingStudy::getBankedRayData ( const RayID  ray_id,
const RayDataIndex  index 
) const

Gets the data value for a banked ray with a given ID.

This will return the value replicated across all processors

Definition at line 1315 of file RayTracingStudy.C.

Referenced by RayDataValue::getValue(), and RayIntegralValue::getValue().

1316 {
1317  return getBankedRayDataInternal(ray_id, index, /* aux = */ false);
1318 }
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 ...

◆ getBankedRayDataInternal()

RayData RayTracingStudy::getBankedRayDataInternal ( const RayID  ray_id,
const RayDataIndex  index,
const bool  aux 
) const
private

Internal method for getting the value (replicated across all processors) in a Ray's data or aux data from the Ray banks.

Definition at line 1302 of file RayTracingStudy.C.

Referenced by getBankedRayAuxData(), and getBankedRayData().

1305 {
1306  // Will be a nullptr shared_ptr if this processor doesn't own the Ray
1307  const std::shared_ptr<Ray> ray = getBankedRay(ray_id);
1308 
1309  Real value = ray ? (aux ? ray->auxData(index) : ray->data(index)) : 0;
1310  _communicator.sum(value);
1311  return value;
1312 }
const Parallel::Communicator & _communicator
std::shared_ptr< Ray > getBankedRay(const RayID ray_id) const
Gets the Ray with the ID ray_id from the Ray bank.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ getCachedTraces()

const std::vector<TraceData>& RayTracingStudy::getCachedTraces ( ) const
inline

Get the cached trace data structure.

Definition at line 595 of file RayTracingStudy.h.

Referenced by RayTracingMeshOutput::buildIDMap(), RayTracingMeshOutput::buildSegmentMesh(), RayTracingMeshOutput::fillFields(), and RayTracingMeshOutput::output().

595 { return _cached_traces; }
std::vector< TraceData > _cached_traces
Storage for the cached traces.

◆ getElemNormals()

virtual const Point* RayTracingStudy::getElemNormals ( const Elem *  ,
const THREAD_ID   
)
inlinevirtual

Gets the outward normals for a given element.

Returns a pointer to the normal for the zeroth side.

Reimplemented in BackfaceCullingStudyTest.

Definition at line 531 of file RayTracingStudy.h.

Referenced by TraceRay::moveThroughNeighbor(), RayTracingStudyTest::RayTracingStudyTest(), and TraceRay::trace().

532  {
533  mooseError("Unimplemented element normal caching in ", type(), "::getElemNormals()");
534  }
const std::string & type() const
void mooseError(Args &&... args) const

◆ getInternalSidesets() [1/2]

const std::vector<std::vector<BoundaryID> >& RayTracingStudy::getInternalSidesets ( const Elem *  elem) const

Get the internal sidesets (that have RayBC(s)) for each side for a given element.

This will be empty if the elem does not have any internal sidesets that have RayBC(s)

Referenced by TraceRay::applyOnInternalBoundary().

◆ getInternalSidesets() [2/2]

const std::set<BoundaryID>& RayTracingStudy::getInternalSidesets ( ) const
inline

Gets the internal sidesets (that have RayBCs) within the local domain.

Definition at line 459 of file RayTracingStudy.h.

Referenced by ViewFactorRayStudy::initialSetup().

459 { return _internal_sidesets; }
std::set< BoundaryID > _internal_sidesets
The BoundaryIDs on the local mesh that have internal RayBCs.

◆ getRayAuxDataIndex()

RayDataIndex RayTracingStudy::getRayAuxDataIndex ( const std::string &  name,
const bool  graceful = false 
) const

Gets the index associated with a registered value in the Ray aux data.

Parameters
nameThe value name to get the index of
gracefulWhether or not to exit gracefully if none is found (return INVALID_RAY_DATA_INDEX)
Returns
The index for the value

Definition at line 1110 of file RayTracingStudy.C.

Referenced by RayDataValue::initialize(), RayTracingStudyTest::RayTracingStudyTest(), and RayTracingMeshOutput::setupEquationSystem().

1112 {
1113  return getRayDataIndexInternal(name, /* aux = */ true, graceful);
1114 }
virtual const std::string & name() const
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.

◆ getRayAuxDataIndices()

std::vector< RayDataIndex > RayTracingStudy::getRayAuxDataIndices ( const std::vector< std::string > &  names,
const bool  graceful = false 
) const

Gets the indices associated with registered values in the Ray aux data.

Parameters
namesThe value names to get the indices of
gracefulWhether or not to exit gracefully if none is found (index is filled with INVALID_RAY_DATA_INDEX)
Returns
The indices for the values

Definition at line 1117 of file RayTracingStudy.C.

1119 {
1120  return getRayDataIndicesInternal(names, /* aux = */ true, graceful);
1121 }
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.

◆ getRayAuxDataName()

const std::string & RayTracingStudy::getRayAuxDataName ( const RayDataIndex  index) const

Gets the name associated with a registered value in the Ray aux data.

Parameters
indexThe index to get the name of
Returns
The name associated with index

Definition at line 1124 of file RayTracingStudy.C.

Referenced by Ray::getInfo().

1125 {
1126  return getRayDataNameInternal(index, /* aux = */ true);
1127 }
const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const
Internal method for getting the name of Ray data or Ray aux data.

◆ getRayAuxDataNames()

std::vector<std::string> RayTracingStudy::getRayAuxDataNames ( const std::vector< RayDataIndex > &  indices) const

Gets the names associated with registered values in the Ray aux data.

Parameters
indicesThe indices to get the names of
Returns
The associated names

◆ getRayBCs() [1/4]

void RayTracingStudy::getRayBCs ( std::vector< RayBoundaryConditionBase *> &  result,
BoundaryID  id,
THREAD_ID  tid 
)

Fills the active RayBCs associated with this study and a boundary into result.

Definition at line 1188 of file RayTracingStudy.C.

Referenced by dependencyChecks(), getRayBCs(), ViewFactorRayStudy::initialSetup(), internalSidesetSetup(), TraceRay::onBoundary(), and RayTracingStudyTest::RayTracingStudyTest().

1191 {
1192  // If the cache doesn't have any attributes yet, it means that we haven't set
1193  // the conditions yet. We do this so that it can be generated on the fly on first use.
1194  if (!_threaded_cache_ray_bc[tid].numAttribs())
1195  {
1196  if (!_called_initial_setup)
1197  mooseError("Should not call getRayBCs() before initialSetup()");
1198 
1199  auto query = _fe_problem.theWarehouse()
1200  .query()
1201  .condition<AttribRayTracingStudy>(this)
1202  .condition<AttribSystem>("RayBoundaryCondition")
1203  .condition<AttribThread>(tid);
1204  _threaded_cache_ray_bc[tid] = query.clone();
1205  }
1206 
1207  _threaded_cache_ray_bc[tid].queryInto(result, std::make_tuple(id, false));
1208 }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
std::vector< TheWarehouse::QueryCache< AttribBoundaries > > _threaded_cache_ray_bc
Threaded cached boundary query for RayBC objects pertaining to this study.
query_obj query
FEProblemBase & _fe_problem
Query query()
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
void mooseError(Args &&... args) const

◆ getRayBCs() [2/4]

template<typename T >
void RayTracingStudy::getRayBCs ( std::vector< T *> &  result,
const std::vector< BoundaryID > &  ids,
THREAD_ID  tid 
)
inline

Fills the active RayBCs associated with this study and boundaries result.

Definition at line 376 of file RayTracingStudy.h.

377  {
379  .query()
380  .condition<AttribRayTracingStudy>(this)
381  .condition<AttribSystem>("RayBoundaryCondition")
382  .condition<AttribBoundaries>(ids)
383  .condition<AttribThread>(tid)
384  .queryInto(result);
385  }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
Query query()

◆ getRayBCs() [3/4]

template<typename T >
void RayTracingStudy::getRayBCs ( std::vector< T *> &  result,
THREAD_ID  tid 
)
inline

Fills the active RayBCs associated with this study into result.

Definition at line 390 of file RayTracingStudy.h.

391  {
393  .query()
394  .condition<AttribRayTracingStudy>(this)
395  .condition<AttribSystem>("RayBoundaryCondition")
396  .condition<AttribThread>(tid)
397  .queryInto(result);
398  }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
Query query()

◆ getRayBCs() [4/4]

void RayTracingStudy::getRayBCs ( std::vector< RayBoundaryConditionBase *> &  result,
const std::vector< TraceRayBndElement > &  bnd_elems,
THREAD_ID  tid,
RayID  ray_id 
)
virtual

Fills the active RayBCs associated with thie study, boundary elements, and potentially Ray into result.

This is purposely virtual because it allows derived studies to optimize the retrieval of RayBCs during the trace in TraceRay.

Definition at line 1211 of file RayTracingStudy.C.

1215 {
1216  // No Ray registration: no need to sift through objects
1217  if (!_use_ray_registration)
1218  {
1219  if (bnd_elems.size() == 1)
1220  getRayBCs(result, bnd_elems[0].bnd_id, tid);
1221  else
1222  {
1223  std::vector<BoundaryID> bnd_ids(bnd_elems.size());
1224  for (MooseIndex(bnd_elems.size()) i = 0; i < bnd_elems.size(); ++i)
1225  bnd_ids[i] = bnd_elems[i].bnd_id;
1226  getRayBCs(result, bnd_ids, tid);
1227  }
1228  }
1229  // Has Ray registration: only pick the objects associated with ray_id
1230  else
1231  {
1232  // Get all of the RayBCs on these boundaries
1233  std::vector<RayBoundaryConditionBase *> rbcs;
1234  if (bnd_elems.size() == 1)
1235  getRayBCs(rbcs, bnd_elems[0].bnd_id, tid);
1236  else
1237  {
1238  std::vector<BoundaryID> bnd_ids(bnd_elems.size());
1239  for (MooseIndex(bnd_elems.size()) i = 0; i < bnd_elems.size(); ++i)
1240  bnd_ids[i] = bnd_elems[i].bnd_id;
1241  getRayBCs(rbcs, bnd_ids, tid);
1242  }
1243 
1244  // The RayTracingObjects associated with this ray
1245  mooseAssert(ray_id < _threaded_ray_object_registration[tid].size(), "Not in registration");
1246  const auto & ray_id_rtos = _threaded_ray_object_registration[tid][ray_id];
1247 
1248  // The result is the union of all of the kernels and the objects associated with this Ray
1249  result.clear();
1250  for (auto rbc : rbcs)
1251  if (ray_id_rtos.count(rbc))
1252  result.push_back(rbc);
1253  }
1254 }
std::vector< std::vector< std::set< const RayTracingObject * > > > _threaded_ray_object_registration
Threaded storage for all of the RayTracingObjects associated with a single Ray.
void getRayBCs(std::vector< RayBoundaryConditionBase *> &result, BoundaryID id, THREAD_ID tid)
Fills the active RayBCs associated with this study and a boundary into result.
const bool _use_ray_registration
Whether or not to use Ray registration.

◆ getRayDataIndex()

RayDataIndex RayTracingStudy::getRayDataIndex ( const std::string &  name,
const bool  graceful = false 
) const

Gets the index associated with a registered value in the Ray data.

Parameters
nameThe value name to get the index of
gracefulWhether or not to exit gracefully if none is found (return INVALID_RAY_DATA_INDEX)
Returns
The index for the value

Definition at line 1079 of file RayTracingStudy.C.

Referenced by RayDataValue::initialize(), RayIntegralValue::initialize(), RayTracingStudyTest::RayTracingStudyTest(), and RayTracingMeshOutput::setupEquationSystem().

1080 {
1081  return getRayDataIndexInternal(name, /* aux = */ false, graceful);
1082 }
virtual const std::string & name() const
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.

◆ getRayDataIndexInternal()

RayDataIndex RayTracingStudy::getRayDataIndexInternal ( const std::string &  name,
const bool  aux,
const bool  graceful 
) const
private

Internal method for getting the index of Ray data or Ray aux data.

Definition at line 1015 of file RayTracingStudy.C.

Referenced by getRayAuxDataIndex(), getRayDataIndex(), and getRayDataIndicesInternal().

1018 {
1019  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1020 
1021  const auto & map = aux ? _ray_aux_data_map : _ray_data_map;
1022  const auto find = map.find(name);
1023  if (find != map.end())
1024  return find->second;
1025 
1026  if (graceful)
1028 
1029  const auto & other_map = aux ? _ray_data_map : _ray_aux_data_map;
1030  if (other_map.find(name) != other_map.end())
1031  mooseError("Ray data with name '",
1032  name,
1033  "' was not found.\n\n",
1034  "However, Ray ",
1035  (aux ? "non-aux" : "aux"),
1036  " data with said name was found.\n",
1037  "Did you mean to use ",
1038  (aux ? "getRayDataIndex()/getRayDataIndices()?"
1039  : "getRayAuxDataIndex()/getRayAuxDataIndices()"),
1040  "?");
1041 
1042  mooseError("Unknown Ray ", (aux ? "aux " : ""), "data with name ", name);
1043 }
static const RayDataIndex INVALID_RAY_DATA_INDEX
Invalid index into a Ray&#39;s data.
Definition: Ray.h:200
if(subdm)
virtual const std::string & name() const
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
std::unordered_map< std::string, RayDataIndex > _ray_aux_data_map
The map from Ray aux data names to index.
std::unordered_map< std::string, RayDataIndex > _ray_data_map
The map from Ray data names to index.
void mooseError(Args &&... args) const

◆ getRayDataIndices()

std::vector< RayDataIndex > RayTracingStudy::getRayDataIndices ( const std::vector< std::string > &  names,
const bool  graceful = false 
) const

Gets the indices associated with registered values in the Ray data.

Parameters
namesThe value names to get the indices of
gracefulWhether or not to exit gracefully if none is found (index is filled with INVALID_RAY_DATA_INDEX)
Returns
The indices for the values

Definition at line 1085 of file RayTracingStudy.C.

1087 {
1088  return getRayDataIndicesInternal(names, /* aux = */ false, graceful);
1089 }
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.

◆ getRayDataIndicesInternal()

std::vector< RayDataIndex > RayTracingStudy::getRayDataIndicesInternal ( const std::vector< std::string > &  names,
const bool  aux,
const bool  graceful 
) const
private

Internal method for getting the indicies of Ray data or Ray aux data.

Definition at line 1046 of file RayTracingStudy.C.

Referenced by getRayAuxDataIndices(), and getRayDataIndices().

1049 {
1050  std::vector<RayDataIndex> indices(names.size());
1051  for (std::size_t i = 0; i < names.size(); ++i)
1052  indices[i] = getRayDataIndexInternal(names[i], aux, graceful);
1053  return indices;
1054 }
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.

◆ getRayDataName()

const std::string & RayTracingStudy::getRayDataName ( const RayDataIndex  index) const

Gets the name associated with a registered value in the Ray data.

Parameters
indexThe index to get the name of
Returns
The name associated with index

Definition at line 1092 of file RayTracingStudy.C.

Referenced by Ray::getInfo(), and RayTracingStudyTest::RayTracingStudyTest().

1093 {
1094  return getRayDataNameInternal(index, /* aux = */ false);
1095 }
const std::string & getRayDataNameInternal(const RayDataIndex index, const bool aux) const
Internal method for getting the name of Ray data or Ray aux data.

◆ getRayDataNameInternal()

const std::string & RayTracingStudy::getRayDataNameInternal ( const RayDataIndex  index,
const bool  aux 
) const
private

Internal method for getting the name of Ray data or Ray aux data.

Definition at line 1057 of file RayTracingStudy.C.

Referenced by getRayAuxDataName(), and getRayDataName().

1058 {
1059  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1060 
1061  if ((aux ? rayAuxDataSize() : rayDataSize()) < index)
1062  mooseError("Unknown Ray ", aux ? "aux " : "", "data with index ", index);
1063  return aux ? _ray_aux_data_names[index] : _ray_data_names[index];
1064 }
std::size_t rayAuxDataSize() const
The registered size of values in the Ray aux data.
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.
void mooseError(Args &&... args) const
std::vector< std::string > _ray_data_names
The names for each Ray data entry.
std::size_t rayDataSize() const
The registered size of values in the Ray data.

◆ getRayDataNames()

std::vector<std::string> RayTracingStudy::getRayDataNames ( const std::vector< RayDataIndex > &  indices) const

Gets the names associated with registered values in the Ray data.

Parameters
indicesThe indices to get the names of
Returns
The associated names

◆ getRayKernels() [1/3]

void RayTracingStudy::getRayKernels ( std::vector< RayKernelBase *> &  result,
SubdomainID  id,
THREAD_ID  tid 
)

Fills the active RayKernels associated with this study and a block into result.

Definition at line 1138 of file RayTracingStudy.C.

Referenced by coverageChecks(), dependencyChecks(), getRayKernels(), hasRayKernels(), initialSetup(), RayTracingStudyTest::RayTracingStudyTest(), segmentSubdomainSetup(), and zeroAuxVariables().

1139 {
1140  // If the cache doesn't have any attributes yet, it means that we haven't set
1141  // the conditions yet. We do this so that it can be generated on the fly on first use.
1142  if (!_threaded_cache_ray_kernel[tid].numAttribs())
1143  {
1144  if (!_called_initial_setup)
1145  mooseError("Should not call getRayKernels() before initialSetup()");
1146 
1147  auto query = _fe_problem.theWarehouse()
1148  .query()
1149  .condition<AttribRayTracingStudy>(this)
1150  .condition<AttribSystem>("RayKernel")
1151  .condition<AttribThread>(tid);
1152  _threaded_cache_ray_kernel[tid] = query.clone();
1153  }
1154 
1155  _threaded_cache_ray_kernel[tid].queryInto(result, id);
1156 }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
std::vector< TheWarehouse::QueryCache< AttribSubdomains > > _threaded_cache_ray_kernel
Threaded cached subdomain query for RayKernelBase objects pertaining to this study.
query_obj query
FEProblemBase & _fe_problem
Query query()
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
void mooseError(Args &&... args) const

◆ getRayKernels() [2/3]

template<typename T >
void RayTracingStudy::getRayKernels ( std::vector< T *> &  result,
THREAD_ID  tid 
)
inline

Fills the active RayKernels associated with this study into result.

Definition at line 354 of file RayTracingStudy.h.

355  {
357  .query()
358  .condition<AttribRayTracingStudy>(this)
359  .condition<AttribSystem>("RayKernel")
360  .condition<AttribThread>(tid)
361  .queryInto(result);
362  }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
Query query()

◆ getRayKernels() [3/3]

void RayTracingStudy::getRayKernels ( std::vector< RayKernelBase *> &  result,
SubdomainID  id,
THREAD_ID  tid,
RayID  ray_id 
)

Fills the active RayKernels associeted with this study, block, and potentially Ray into result.

Definition at line 1159 of file RayTracingStudy.C.

1163 {
1164  // No Ray registration: no need to sift through objects
1165  if (!_use_ray_registration)
1166  {
1167  getRayKernels(result, id, tid);
1168  }
1169  // Has Ray registration: only pick the objects associated with ray_id
1170  else
1171  {
1172  // Get all of the kernels on this block
1173  std::vector<RayKernelBase *> rkbs;
1174  getRayKernels(rkbs, id, tid);
1175 
1176  // The RayTracingObjects associated with this ray
1177  const auto & ray_id_rtos = _threaded_ray_object_registration[tid][ray_id];
1178 
1179  // The result is the union of all of the kernels and the objects associated with this Ray
1180  result.clear();
1181  for (auto rkb : rkbs)
1182  if (ray_id_rtos.count(rkb))
1183  result.push_back(rkb);
1184  }
1185 }
void getRayKernels(std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.
std::vector< std::vector< std::set< const RayTracingObject * > > > _threaded_ray_object_registration
Threaded storage for all of the RayTracingObjects associated with a single Ray.
const bool _use_ray_registration
Whether or not to use Ray registration.

◆ getRayTracingObjects()

std::vector< RayTracingObject * > RayTracingStudy::getRayTracingObjects ( )
protected

Gets all of the currently active RayTracingObjects.

Definition at line 1257 of file RayTracingStudy.C.

Referenced by executeStudy(), initialSetup(), jacobianSetup(), registeredRaySetup(), residualSetup(), and timestepSetup().

1258 {
1259  std::vector<RayTracingObject *> result;
1260  _fe_problem.theWarehouse().query().condition<AttribRayTracingStudy>(this).queryInto(result);
1261  return result;
1262 }
Attribute for the RayTracingStudy a RayTracingObject is associated with.
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
Query query()

◆ getSideNormal()

const Point & RayTracingStudy::getSideNormal ( const Elem elem,
const unsigned short  side,
const THREAD_ID  tid 
)
virtual

Get the outward normal for a given element side.

Definition at line 1550 of file RayTracingStudy.C.

Referenced by LotsOfRaysRayStudy::defineRays(), BackfaceCullingStudyTest::generateNormals(), ViewFactorRayStudy::generateRays(), TraceRay::getPointNeighbors(), ReflectRayBC::onBoundary(), sideIsIncoming(), and TraceRay::trace().

1551 {
1552  std::unordered_map<std::pair<const Elem *, unsigned short>, Point> & cache =
1554 
1555  // See if we've already cached this side normal
1556  const auto elem_side_pair = std::make_pair(elem, side);
1557  const auto search = cache.find(elem_side_pair);
1558 
1559  // Haven't cached this side normal: compute it and then cache it
1560  if (search == cache.end())
1561  {
1562  _threaded_fe_face[tid]->reinit(elem, side);
1563  const auto & normal = _threaded_fe_face[tid]->get_normals()[0];
1564  cache.emplace(elem_side_pair, normal);
1565  return normal;
1566  }
1567 
1568  // Have cached this side normal: simply return it
1569  return search->second;
1570 }
std::vector< std::unique_ptr< libMesh::FEBase > > _threaded_fe_face
Face FE used for computing face normals for each thread.
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.

◆ hasInternalSidesets()

bool RayTracingStudy::hasInternalSidesets ( ) const
inline

Whether or not the local mesh has internal sidesets that have RayBCs on them.

NOTE: if useInternalSidesets() == false, this will be false even if the mesh does have internal sidesets

Definition at line 449 of file RayTracingStudy.h.

Referenced by TraceRay::applyOnInternalBoundary(), and TraceRay::trace().

449 { return _internal_sidesets.size(); }
std::set< BoundaryID > _internal_sidesets
The BoundaryIDs on the local mesh that have internal RayBCs.

◆ hasRayAuxData()

bool RayTracingStudy::hasRayAuxData ( ) const
inline

Whether or not any Ray aux data are registered.

Definition at line 336 of file RayTracingStudy.h.

336 { return _ray_aux_data_names.size(); }
std::vector< std::string > _ray_aux_data_names
The names for each Ray aux data entry.

◆ hasRayData()

bool RayTracingStudy::hasRayData ( ) const
inline

Whether or not any Ray data are registered.

Definition at line 276 of file RayTracingStudy.h.

Referenced by RayTracingMeshOutput::fillFields().

276 { return _ray_data_names.size(); }
std::vector< std::string > _ray_data_names
The names for each Ray data entry.

◆ hasRayKernels()

bool RayTracingStudy::hasRayKernels ( const THREAD_ID  tid)

Whether or not there are currently any active RayKernel objects.

Definition at line 1130 of file RayTracingStudy.C.

Referenced by ViewFactorRayStudy::initialSetup(), and TraceRay::preExecute().

1131 {
1132  std::vector<RayKernelBase *> result;
1133  getRayKernels(result, tid);
1134  return result.size();
1135 }
void getRayKernels(std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.

◆ hasSameLevelActiveElems()

bool RayTracingStudy::hasSameLevelActiveElems ( ) const
inline

Whether or not the mesh has active elements of the same level.

Use this over sameLevelActiveElems(), which is for internally setting _has_same_level_active_elems

Definition at line 475 of file RayTracingStudy.h.

Referenced by TraceRay::applyOnInternalBoundary(), and TraceRay::trace().

bool _has_same_level_active_elems
Whether or not the mesh has active elements of the same level.

◆ initialize()

virtual void RayTracingStudy::initialize ( )
inlineoverridevirtual

Implements GeneralUserObject.

Definition at line 80 of file RayTracingStudy.h.

80 {}

◆ initialSetup()

void RayTracingStudy::initialSetup ( )
overridevirtual

Reimplemented from GeneralUserObject.

Reimplemented in BackfaceCullingStudyTest, and ViewFactorRayStudy.

Definition at line 226 of file RayTracingStudy.C.

Referenced by ViewFactorRayStudy::initialSetup(), and BackfaceCullingStudyTest::initialSetup().

227 {
228  // Keep track of initialSetup call to avoid registration of various things
229  _called_initial_setup = true;
230 
231  // Sets up a local index for each elem this proc knows about
233 
234  // Check for RayKernel coverage
235  coverageChecks();
236 
237  // Make sure the dependencies exist, if any
239 
240  // Check for traceable element types
242 
243  // Setup for internal sidesets
245 
247 
248  // Setup approximate hmax for each subdomain
250 
251  // Call initial setup on all of the objects
252  for (auto & rto : getRayTracingObjects())
253  rto->initialSetup();
254 
255  // Check for proper exec flags with RayKernels
256  std::vector<RayKernelBase *> ray_kernels;
257  getRayKernels(ray_kernels, 0);
258  for (const auto & rkb : ray_kernels)
259  if (dynamic_cast<RayKernel *>(rkb) && !_execute_enum.isValueSet(EXEC_PRE_KERNELS))
260  mooseError("This study has RayKernel objects that contribute to residuals and Jacobians.",
261  "\nIn this case, the study must use the execute_on = PRE_KERNELS");
262 
263  // Build 1D quadrature rule for along a segment
265  QBase::build(QGAUSS, 1, _fe_problem.getSystemBase(_sys.number()).getMinQuadratureOrder());
266 }
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.
void traceableMeshChecks()
Check for if all of the element types in the mesh are supported by ray tracing.
void nonPlanarSideSetup()
Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar...
void coverageChecks()
Perform coverage checks (coverage of RayMaterials and RayKernels, if enabled)
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
void dependencyChecks()
Perform checks to see if the listed dependencies in the RayTracingObjects exist.
SystemBase & _sys
bool isValueSet(const std::string &value) const
unsigned int number() const
const ExecFlagEnum & _execute_enum
virtual const SystemBase & getSystemBase(const unsigned int sys_num) const
FEProblemBase & _fe_problem
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
void mooseError(Args &&... args) const
void localElemIndexSetup()
Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that ...
void subdomainHMaxSetup()
Caches the hmax for all elements in each subdomain.
std::unique_ptr< libMesh::QBase > _segment_qrule
Quadrature rule for laying points across a 1D ray segment.

◆ initThreadedCachedTrace()

TraceData & RayTracingStudy::initThreadedCachedTrace ( const std::shared_ptr< Ray > &  ray,
THREAD_ID  tid 
)

Initialize a Ray in the threaded cached trace map to be filled with segments.

Definition at line 1409 of file RayTracingStudy.C.

Referenced by TraceRay::trace().

1410 {
1411  mooseAssert(shouldCacheTrace(ray), "Not caching trace");
1412  mooseAssert(currentlyPropagating(), "Should only use while tracing");
1413 
1414  _threaded_cached_traces[tid].emplace_back(ray);
1415  return _threaded_cached_traces[tid].back();
1416 }
std::vector< std::vector< TraceData > > _threaded_cached_traces
The threaded storage for cached traces.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
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)...

◆ internalSidesetSetup()

void RayTracingStudy::internalSidesetSetup ( )
private

Does the setup for internal sidesets.

This includes:

  • Setting if the local mesh has internal sidesets that have RayBCs and on which boundary (stored in _internal_sidesets)
  • Sets up the internal sideset mapping that maps element sides to the BoundaryIDs on said side that have internal sidesets that have RayBCs (stored in _internal_sidesets_map)

If _use_internal_sidesets == false, this will still check to make sure that the user does not have internal sidesets with RayBCs on them, and will report an error if so.

Definition at line 412 of file RayTracingStudy.C.

Referenced by initialSetup(), and meshChanged().

413 {
414  // Even if we have _use_internal_sidesets == false, we will make sure the user didn't add RayBCs
415  // on internal boundaries
416 
417  // Clear the data structures and size the map based on the elements that we know about
418  _internal_sidesets.clear();
419  _internal_sidesets_map.clear();
421 
422  // First, we are going to store all elements with internal sidesets (if any) that have active
423  // RayBCs on them as elem -> vector of (side, vector of boundary ids)
424  for (const auto & bnd_elem : *_mesh.getBoundaryElementRange())
425  {
426  Elem * elem = bnd_elem->_elem;
427  const unsigned int side = bnd_elem->_side;
428  const auto bnd_id = bnd_elem->_bnd_id;
429 
430  // Not internal
431  const Elem * const neighbor = elem->neighbor_ptr(side);
432  if (!neighbor || neighbor == remote_elem)
433  continue;
434 
435  // No RayBCs on this sideset
436  std::vector<RayBoundaryConditionBase *> result;
437  getRayBCs(result, bnd_id, 0);
438  if (result.empty())
439  continue;
440 
441  if (neighbor->subdomain_id() == elem->subdomain_id())
442  mooseError("RayBCs exist on internal sidesets that are not bounded by a different",
443  "\nsubdomain on each side.",
444  "\n\nIn order to use RayBCs on internal sidesets, said sidesets must have",
445  "\na different subdomain on each side.");
446 
447  // Mark that this boundary is an internal sideset with RayBC(s)
448  _internal_sidesets.insert(bnd_id);
449 
450  // Get elem's entry in the internal sidset data structure
451  const auto index = _elem_index_helper.getIndex(elem);
452  auto & entry = _internal_sidesets_map[index];
453 
454  // Initialize this elem's sides if they have not been already
455  if (entry.empty())
456  entry.resize(elem->n_sides(), std::vector<BoundaryID>());
457 
458  // Add the internal boundary to the side entry
459  entry[side].push_back(bnd_id);
460  }
461 
463  mooseError("RayBCs are defined on internal sidesets, but the study is not set to use ",
464  "internal sidesets during tracing.",
465  "\n\nSet the parameter use_internal_sidesets = true to enable this capability.");
466 }
MooseMesh & _mesh
The Mesh.
const bool _use_internal_sidesets
Whether or not to use the internal sidesets in ray tracing.
libMesh::dof_id_type maxIndex() const
Gets the maximum index generated using this object.
std::set< BoundaryID > _internal_sidesets
The BoundaryIDs on the local mesh that have internal RayBCs.
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
virtual unsigned int n_sides() const=0
const Elem * neighbor_ptr(unsigned int i) const
subdomain_id_type subdomain_id() const
void getRayBCs(std::vector< RayBoundaryConditionBase *> &result, BoundaryID id, THREAD_ID tid)
Fills the active RayBCs associated with this study and a boundary into result.
void mooseError(Args &&... args) const
libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement *> * getBoundaryElementRange()
std::vector< std::vector< std::vector< BoundaryID > > > _internal_sidesets_map
Internal sideset data, if internal sidesets exist (indexed with getLocalElemIndex()) ...

◆ isRectangularDomain()

bool RayTracingStudy::isRectangularDomain ( ) const

Whether or not the domain is rectangular (if it is prefectly encompassed by its bounding box)

Definition at line 1601 of file RayTracingStudy.C.

Referenced by LotsOfRaysRayStudy::LotsOfRaysRayStudy(), and TraceRay::preExecute().

1602 {
1603  Real bbox_volume = 1;
1604  for (unsigned int d = 0; d < _mesh.dimension(); ++d)
1605  bbox_volume *= std::abs(_b_box.max()(d) - _b_box.min()(d));
1606 
1607  return MooseUtils::absoluteFuzzyEqual(bbox_volume, totalVolume(), TOLERANCE);
1608 }
Real totalVolume() const
Get the current total volume of the domain.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
MooseMesh & _mesh
The Mesh.
virtual unsigned int dimension() const
const Point & min() const
libMesh::BoundingBox _b_box
Nodal bounding box for the domain.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Point & max() const

◆ jacobianSetup()

void RayTracingStudy::jacobianSetup ( )
overridevirtual

Reimplemented from GeneralUserObject.

Definition at line 279 of file RayTracingStudy.C.

280 {
281  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
282  mooseAssert(_num_cached[tid] == 0, "Cached residuals/Jacobians not empty");
283 
284  for (auto & rto : getRayTracingObjects())
285  rto->jacobianSetup();
286 }
unsigned int n_threads()
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
unsigned int THREAD_ID

◆ localElemIndexSetup()

void RayTracingStudy::localElemIndexSetup ( )
private

Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that this processor knows about.

Said index is used for quickly accessing things like internal sidesets and checking if an element side is non-planar during tracing.

Definition at line 404 of file RayTracingStudy.C.

Referenced by initialSetup(), and meshChanged().

405 {
406  // TODO: We could probably minimize this to local active elements followed by
407  // boundary point neighbors, but if using distibuted mesh it really shouldn't matter
408  _elem_index_helper.initialize(_mesh.getMesh().active_element_ptr_range());
409 }
MooseMesh & _mesh
The Mesh.
void initialize(const libMesh::SimpleRange< libMesh::MeshBase::element_iterator > elems)
Initializes the indices in a contiguous manner for the given element range.
MeshBase & getMesh()
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.

◆ localTraceRayResult()

unsigned long long int RayTracingStudy::localTraceRayResult ( const int  result) const
inline

Definition at line 174 of file RayTracingStudy.h.

Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().

175  {
176  return _local_trace_ray_results[result];
177  }
std::vector< unsigned long long int > _local_trace_ray_results
Cumulative results on this processor from the threaded TraceRay objects.

◆ looseBoundingBox()

const BoundingBox& RayTracingStudy::looseBoundingBox ( ) const
inline

Get the loose nodal bounding box for the domain.

BoundingBox::contains_point does not have a tolerance, so we need to stretch the box a little bit for some contains_point checks.

Definition at line 429 of file RayTracingStudy.h.

Referenced by Ray::setStart(), and Ray::setStartingEndPoint().

429 { return _loose_b_box; }
libMesh::BoundingBox _loose_b_box
Loose nodal bounding box for the domain.

◆ maxIntersections()

unsigned int RayTracingStudy::maxIntersections ( ) const
inline

Max number of intersections for a Ray.

Definition at line 159 of file RayTracingStudy.h.

159 { return _max_intersections; }
unsigned int _max_intersections
Max number of intersections for a single Ray.

◆ maxProcessorCrossings()

unsigned int RayTracingStudy::maxProcessorCrossings ( ) const
inline

Max number of processor crossings for all Rays.

Definition at line 142 of file RayTracingStudy.h.

Referenced by RayTracingStudyResult::getValue().

142 { return _max_processor_crossings; }
unsigned int _max_processor_crossings
Max number of processor crossings for all Rays.

◆ maxTrajectoryChanges()

unsigned int RayTracingStudy::maxTrajectoryChanges ( ) const
inline

Max number of trajectory changes for a Ray.

Definition at line 163 of file RayTracingStudy.h.

163 { return _max_trajectory_changes; }
unsigned int _max_trajectory_changes
Max number of trajectory changes for a single Ray.

◆ mesh()

MooseMesh& RayTracingStudy::mesh ( )
inline
Returns
A reference to the MooseMesh associated with this study.

Definition at line 520 of file RayTracingStudy.h.

520 { return _mesh; }
MooseMesh & _mesh
The Mesh.

◆ meshBase()

MeshBase& RayTracingStudy::meshBase ( ) const
inline

◆ meshChanged()

void RayTracingStudy::meshChanged ( )
overridevirtual

Reimplemented from GeneralUserObject.

Reimplemented in RepeatableRayStudyBase, and BackfaceCullingStudyTest.

Definition at line 296 of file RayTracingStudy.C.

Referenced by RepeatableRayStudyBase::meshChanged().

297 {
302 
304 
305  for (const auto & trace_ray : _threaded_trace_ray)
306  trace_ray->meshChanged();
307 }
void internalSidesetSetup()
Does the setup for internal sidesets.
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...
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)
void nonPlanarSideSetup()
Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar...
void localElemIndexSetup()
Sets up the _elem_index_helper, which is used for obtaining a contiguous index for all elements that ...
void subdomainHMaxSetup()
Caches the hmax for all elements in each subdomain.

◆ moveRaysToBuffer()

void RayTracingStudy::moveRaysToBuffer ( std::vector< std::shared_ptr< Ray >> &  rays)
protected

Moves rays to the buffer to be traced during generateRays().

This moves the rays into the buffer (with std::move), therefore all valid rays in rays will be nullptr after this call.

Definition at line 1515 of file RayTracingStudy.C.

Referenced by TestPICRayStudy::generateRays(), TestReuseRaysStudy::generateRays(), and TestTransientRaysStudy::generateRays().

1516 {
1517  mooseAssert(currentlyGenerating(), "Can only use while generating");
1518 #ifndef NDEBUG
1519  for (const std::shared_ptr<Ray> & ray : rays)
1520  {
1521  mooseAssert(ray, "Null ray");
1522  mooseAssert(ray->shouldContinue(), "Ray is not continuing");
1523  }
1524 #endif
1525 
1526  _parallel_ray_study->moveWorkToBuffer(rays, /* tid = */ 0);
1527 }
bool currentlyGenerating() const
Whether or not the study is generating.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ moveRayToBuffer()

void RayTracingStudy::moveRayToBuffer ( std::shared_ptr< Ray > &  ray)
protected

Moves a ray to the buffer to be traced during generateRays().

This moves the Ray into the buffer (with std::move), therefore ray will be nullptr after this call.

Definition at line 1505 of file RayTracingStudy.C.

Referenced by RayTracingStudyTest::generateRays(), StationaryRayStudyTest::generateRays(), TestReuseRaysStudy::generateRays(), TestTransientRaysStudy::generateRays(), RepeatableRayStudyBase::generateRays(), and ViewFactorRayStudy::generateRays().

1506 {
1507  mooseAssert(currentlyGenerating(), "Can only use while generating");
1508  mooseAssert(ray, "Null ray");
1509  mooseAssert(ray->shouldContinue(), "Ray is not continuing");
1510 
1511  _parallel_ray_study->moveWorkToBuffer(ray, /* tid = */ 0);
1512 }
bool currentlyGenerating() const
Whether or not the study is generating.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ moveRayToBufferDuringTrace()

void RayTracingStudy::moveRayToBufferDuringTrace ( std::shared_ptr< Ray > &  ray,
const THREAD_ID  tid,
const AcquireMoveDuringTraceKey  
)

INTERNAL method for moving a Ray into the buffer during tracing.

You should not and cannot use this API. It is protected by the AcquireMoveDuringTraceKey, which is only constructable by RayKernelBase and RayBoundaryConditionBase.

Definition at line 1530 of file RayTracingStudy.C.

Referenced by RayBoundaryConditionBase::moveRayToBuffer(), and RayKernelBase::moveRayToBuffer().

1533 {
1534  mooseAssert(ray, "Null ray");
1535  mooseAssert(currentlyPropagating(), "Can only use while tracing");
1536 
1537  _parallel_ray_study->moveWorkToBuffer(ray, tid);
1538 }
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)

◆ nonPlanarSideSetup()

void RayTracingStudy::nonPlanarSideSetup ( )
private

Sets up the caching of whether or not each element side is non-planar, which is stored in _non_planar_sides.

This is done because this check is made within TraceRay, and determining whether or not a side is non planar is quite expensive and we don't want to call it mid-trace.

Definition at line 469 of file RayTracingStudy.C.

Referenced by initialSetup(), and meshChanged().

470 {
471  _has_non_planar_sides = false;
472  bool warned = !_warn_non_planar;
473 
474  // Nothing to do here for 2D or 1D
475  if (_mesh.dimension() != 3)
476  return;
477 
478  // Clear the data structure and size it based on the elements that we know about
479  _non_planar_sides.clear();
481 
482  for (const Elem * elem : _mesh.getMesh().active_element_ptr_range())
483  {
484  const auto index = _elem_index_helper.getIndex(elem);
485  auto & entry = _non_planar_sides[index];
486  entry.resize(elem->n_sides(), 0);
487 
488  for (const auto s : elem->side_index_range())
489  {
490  const auto & side = elemSide(*elem, s);
491  if (side.n_vertices() < 4)
492  continue;
493 
494  if (!side.has_affine_map())
495  {
496  entry[s] = 1;
497  _has_non_planar_sides = true;
498 
499  if (!warned)
500  {
501  mooseWarning("The mesh contains non-planar faces.\n\n",
502  "Ray tracing on non-planar faces is an approximation and may fail.\n\n",
503  "Use at your own risk! You can disable this warning by setting the\n",
504  "parameter 'warn_non_planar' to false.");
505  warned = true;
506  }
507  }
508  }
509  }
510 }
MooseMesh & _mesh
The Mesh.
libMesh::dof_id_type maxIndex() const
Gets the maximum index generated using this object.
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 mooseWarning(Args &&... args) const
MeshBase & getMesh()
virtual unsigned int dimension() const
const bool _warn_non_planar
Whether not to warn if non-planar faces are found.
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
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.

◆ onCompleteRay()

void RayTracingStudy::onCompleteRay ( const std::shared_ptr< Ray > &  ray)
virtual

Entry point for acting on a ray when it is completed (shouldContinue() == false)

Reimplemented in TestRayDataStudy.

Definition at line 954 of file RayTracingStudy.C.

Referenced by TestRayDataStudy::onCompleteRay(), and ParallelRayStudy::postExecuteChunk().

955 {
956  mooseAssert(currentlyPropagating(), "Should only be called during Ray propagation");
957 
958  _ending_processor_crossings += ray->processorCrossings();
960  std::max(_ending_max_processor_crossings, ray->processorCrossings());
961  _ending_intersections += ray->intersections();
962  _ending_max_intersections = std::max(_ending_max_intersections, ray->intersections());
964  std::max(_ending_max_trajectory_changes, ray->trajectoryChanges());
965  _ending_distance += ray->distance();
966 
967 #ifdef NDEBUG
968  // In non-opt modes, we will always bank the Rays for debugging
970 #endif
971  _ray_bank.emplace_back(ray);
972 }
unsigned long long int _ending_intersections
Total number of Ray/element intersections for Rays that finished on this processor.
Real _ending_distance
Total distance traveled by Rays that end on this processor.
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.
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. ...
unsigned long long int _ending_processor_crossings
Total number of processor crossings for Rays that finished on this processor.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
std::vector< std::shared_ptr< Ray > > _ray_bank
Cumulative Ray bank - stored only when _bank_rays_on_completion.

◆ parallelRayStudy()

const ParallelRayStudy& RayTracingStudy::parallelRayStudy ( ) const
inline

Definition at line 179 of file RayTracingStudy.h.

Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute(), and RayTracingStudyResult::getValue().

179 { return *_parallel_ray_study; }
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ parallelStudy()

ParallelStudy<std::shared_ptr<Ray>, Ray>* RayTracingStudy::parallelStudy ( )
inline

The underlying parallel study: used for the context for calling the packed range routines.

Definition at line 678 of file RayTracingStudy.h.

Referenced by RayTracingStudyTest::generateRays(), and RepeatableRayStudyBase::verifyReplicatedRays().

678 { return _parallel_ray_study.get(); }
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.

◆ postExecuteStudy()

virtual void RayTracingStudy::postExecuteStudy ( )
inlineprotectedvirtual

Entry point after study execution.

Reimplemented in ViewFactorRayStudy, TestTransientRaysStudy, TestReuseRaysStudy, TestPICRayStudy, RayTracingStudyTest, and TestRayLots.

Definition at line 709 of file RayTracingStudy.h.

Referenced by executeStudy().

709 {}

◆ postOnSegment()

void RayTracingStudy::postOnSegment ( const THREAD_ID  tid,
const std::shared_ptr< Ray > &  ray 
)
virtual

Called at the end of a Ray segment.

Parameters
tidThread id
rayThe ray

Definition at line 738 of file RayTracingStudy.C.

Referenced by TraceRay::trace().

739 {
740  mooseAssert(currentlyPropagating(), "Should not call while not propagating");
742  mooseAssert(_num_cached[tid] == 0,
743  "Values should only be cached when computing Jacobian/residual");
744 
745  // Fill into cached Jacobian/residuals if necessary
747  {
749 
750  if (++_num_cached[tid] == 20)
751  {
752  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
754  _num_cached[tid] = 0;
755  }
756  }
758  {
760 
761  if (++_num_cached[tid] == 20)
762  {
763  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
765  _num_cached[tid] = 0;
766  }
767  }
768 }
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
const bool & currentlyComputingResidual() const
virtual void cacheResidual(const THREAD_ID tid) override
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
FEProblemBase & _fe_problem
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
const bool & currentlyComputingJacobian() const
virtual void cacheJacobian(const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ preExecuteStudy()

virtual void RayTracingStudy::preExecuteStudy ( )
inlineprotectedvirtual

Entry point before study execution.

Reimplemented in ViewFactorRayStudy.

Definition at line 705 of file RayTracingStudy.h.

Referenced by executeStudy().

705 {}

◆ preTrace()

virtual void RayTracingStudy::preTrace ( const THREAD_ID  ,
const std::shared_ptr< Ray > &   
)
inlinevirtual

Called at the beginning of a trace for a ray.

Parameters
tidThread id
rayThe ray

Definition at line 120 of file RayTracingStudy.h.

Referenced by TraceRay::trace().

120 {}

◆ propagationTime()

Real RayTracingStudy::propagationTime ( ) const
inline

Duration for creation of all Rays in seconds.

Definition at line 204 of file RayTracingStudy.h.

Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().

204 { return std::chrono::duration<Real>(_propagation_time).count(); }
std::chrono::steady_clock::duration _propagation_time

◆ rayAuxDataNames()

const std::vector<std::string>& RayTracingStudy::rayAuxDataNames ( ) const
inline

The Ray aux data names.

Definition at line 340 of file RayTracingStudy.h.

Referenced by RayTracingMeshOutput::setupEquationSystem().

340 { return _ray_aux_data_names; }
std::vector< std::string > _ray_aux_data_names
The names for each Ray aux data entry.

◆ rayAuxDataSize()

std::size_t RayTracingStudy::rayAuxDataSize ( ) const
inline

The registered size of values in the Ray aux data.

Definition at line 332 of file RayTracingStudy.h.

Referenced by acquireRay(), acquireRayDuringTrace(), acquireRegisteredRay(), acquireReplicatedRay(), Ray::auxData(), and getRayDataNameInternal().

332 { return _ray_aux_data_names.size(); }
std::vector< std::string > _ray_aux_data_names
The names for each Ray aux data entry.

◆ rayBank()

const std::vector< std::shared_ptr< Ray > > & RayTracingStudy::rayBank ( ) const
protected

Get the Ray bank.

This is the bank of Rays that have completed on this processor after an execution of the study.

This is only available when the private parameter _bank_rays_on_completion is set to true.

Definition at line 1265 of file RayTracingStudy.C.

Referenced by RayTracingStudyTest::generateRays(), getBankedRay(), TestRayLots::postExecuteStudy(), RayTracingStudyTest::postExecuteStudy(), TestPICRayStudy::postExecuteStudy(), TestReuseRaysStudy::postExecuteStudy(), TestTransientRaysStudy::postExecuteStudy(), and RayTracingStudyNoBankingTest::RayTracingStudyNoBankingTest().

1266 {
1268  mooseError("The Ray bank is not available because the private parameter "
1269  "'_bank_rays_on_completion' is set to false.");
1271  mooseError("Cannot get the Ray bank during generation or propagation.");
1272 
1273  return _ray_bank;
1274 }
bool currentlyGenerating() const
Whether or not the study is generating.
const bool _bank_rays_on_completion
Whether or not to bank rays on completion.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
void mooseError(Args &&... args) const
std::vector< std::shared_ptr< Ray > > _ray_bank
Cumulative Ray bank - stored only when _bank_rays_on_completion.

◆ rayDataNames()

const std::vector<std::string>& RayTracingStudy::rayDataNames ( ) const
inline

The Ray data names.

Definition at line 280 of file RayTracingStudy.h.

Referenced by RayTracingExodus::outputMesh(), RayTracingNemesis::outputMesh(), and RayTracingMeshOutput::setupEquationSystem().

280 { return _ray_data_names; }
std::vector< std::string > _ray_data_names
The names for each Ray data entry.

◆ rayDataSize()

std::size_t RayTracingStudy::rayDataSize ( ) const
inline

The registered size of values in the Ray data.

Definition at line 272 of file RayTracingStudy.h.

Referenced by acquireRay(), acquireRayDuringTrace(), acquireRegisteredRay(), acquireReplicatedRay(), Ray::data(), and getRayDataNameInternal().

272 { return _ray_data_names.size(); }
std::vector< std::string > _ray_data_names
The names for each Ray data entry.

◆ rayDependentSubdomainSetup()

bool RayTracingStudy::rayDependentSubdomainSetup ( ) const
inline

Whether or not to use Ray dependent subdomain setup.

Definition at line 219 of file RayTracingStudy.h.

Referenced by TraceRay::trace().

const bool _ray_dependent_subdomain_setup
Whether or not subdomain setup is dependent on the Ray.

◆ rayMaxDistance()

Real RayTracingStudy::rayMaxDistance ( ) const
inline

Max distance any Ray can travel.

Definition at line 184 of file RayTracingStudy.h.

Referenced by TraceRay::trace().

184 { return _ray_max_distance; }
const Real _ray_max_distance
Max distance a Ray can travel before being killed (can change)

◆ registeredRayID()

RayID RayTracingStudy::registeredRayID ( const std::string &  name,
const bool  graceful = false 
) const

Gets the ID of a registered ray.

Parameters
nameThe name of said ray
gracefulWhether or not to exit gracefully if none is found (with invalid_id)

Definition at line 1351 of file RayTracingStudy.C.

Referenced by RayDataValue::getValue(), RayIntegralValue::initialize(), RayTracingStudyTest::RayTracingStudyTest(), RayTracingStudyWithRegistrationTest::RayTracingStudyWithRegistrationTest(), and registeredRaySetup().

1352 {
1353  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1354 
1355  if (!_use_ray_registration)
1356  mooseError("Should not use registeredRayID() with Ray registration disabled");
1357 
1358  const auto search = _registered_ray_map.find(name);
1359  if (search != _registered_ray_map.end())
1360  return search->second;
1361 
1362  if (graceful)
1363  return Ray::INVALID_RAY_ID;
1364 
1365  mooseError("Attempted to obtain ID of registered Ray ",
1366  name,
1367  ", but a Ray with said name is not registered.");
1368 }
if(subdm)
virtual const std::string & name() const
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
void mooseError(Args &&... args) const
std::unordered_map< std::string, RayID > & _registered_ray_map
Map from registered Ray name to ID.
const bool _use_ray_registration
Whether or not to use Ray registration.
static const RayID INVALID_RAY_ID
Invalid Ray ID.
Definition: Ray.h:202

◆ registeredRayName()

const std::string & RayTracingStudy::registeredRayName ( const RayID  ray_id) const

Gets the name of a registered ray.

Parameters
ray_idThe ID of said ray

Definition at line 1371 of file RayTracingStudy.C.

Referenced by Ray::getInfo(), RayTracingStudyTest::RayTracingStudyTest(), and RayTracingStudyWithRegistrationTest::RayTracingStudyWithRegistrationTest().

1372 {
1373  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1374 
1375  if (!_use_ray_registration)
1376  mooseError("Should not use registeredRayName() with Ray registration disabled");
1377 
1378  if (_reverse_registered_ray_map.size() > ray_id)
1379  return _reverse_registered_ray_map[ray_id];
1380 
1381  mooseError("Attempted to obtain name of registered Ray with ID ",
1382  ray_id,
1383  ", but a Ray with said ID is not registered.");
1384 }
std::vector< std::string > & _reverse_registered_ray_map
Map from registered Ray ID to name.
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
void mooseError(Args &&... args) const
const bool _use_ray_registration
Whether or not to use Ray registration.

◆ registeredRaySetup()

void RayTracingStudy::registeredRaySetup ( )
private

Sets up the maps from Ray to associated RayTracingObjects if _use_ray_registration.

If ray registration is disabled, this makes sure no RayTracingObjects provided rays.

Definition at line 567 of file RayTracingStudy.C.

Referenced by executeStudy().

568 {
569  // First, clear the objects associated with each Ray on each thread
570  const auto num_rays = _registered_ray_map.size();
571  for (auto & entry : _threaded_ray_object_registration)
572  {
573  entry.clear();
574  entry.resize(num_rays);
575  }
576 
577  const auto rtos = getRayTracingObjects();
578 
580  {
581  // All of the registered ray names - used when a RayTracingObject did not specify
582  // any Rays so it should be associated with all Rays.
583  std::vector<std::string> all_ray_names;
584  all_ray_names.reserve(_registered_ray_map.size());
585  for (const auto & pair : _registered_ray_map)
586  all_ray_names.push_back(pair.first);
587 
588  for (auto & rto : rtos)
589  {
590  // The Ray names associated with this RayTracingObject
591  const auto & ray_names = rto->parameters().get<std::vector<std::string>>("rays");
592  // The registration for RayTracingObjects for the thread rto is on
593  const auto tid = rto->parameters().get<THREAD_ID>("_tid");
594  auto & registration = _threaded_ray_object_registration[tid];
595 
596  // Register each Ray for this object in the registration
597  for (const auto & ray_name : (ray_names.empty() ? all_ray_names : ray_names))
598  {
599  const auto id = registeredRayID(ray_name, /* graceful = */ true);
600  if (ray_names.size() && id == Ray::INVALID_RAY_ID)
601  rto->paramError(
602  "rays", "Supplied ray '", ray_name, "' is not a registered Ray in ", typeAndName());
603  registration[id].insert(rto);
604  }
605  }
606  }
607  // Not using Ray registration
608  else
609  {
610  for (const auto & rto : rtos)
611  if (rto->parameters().get<std::vector<std::string>>("rays").size())
612  rto->paramError(
613  "rays",
614  "Rays cannot be supplied when the study does not require Ray registration.\n\n",
615  type(),
616  " does not require Ray registration.");
617  }
618 }
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< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
const std::string & type() const
std::string typeAndName() const
std::unordered_map< std::string, RayID > & _registered_ray_map
Map from registered Ray name to ID.
RayID registeredRayID(const std::string &name, const bool graceful=false) const
Gets the ID of a registered ray.
const bool _use_ray_registration
Whether or not to use Ray registration.
static const RayID INVALID_RAY_ID
Invalid Ray ID.
Definition: Ray.h:202
unsigned int THREAD_ID

◆ registerRay()

RayID RayTracingStudy::registerRay ( const std::string &  name)
private

Registers a Ray with a given name.

This is for internal use only and is an internal map for replicated Ray IDs -> names for easy access for studies that have a small number of rays to generate.

Parameters
nameThe name to register
Returns
The allocated ID for the registered ray

Definition at line 1327 of file RayTracingStudy.C.

Referenced by acquireRegisteredRay().

1328 {
1329  libmesh_parallel_only(comm());
1330 
1331  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1332 
1333  if (!_use_ray_registration)
1334  mooseError("Cannot use registerRay() with Ray registration disabled");
1335 
1336  // This is parallel only for now. We could likely stagger the ID building like we do with
1337  // the unique IDs, but it would require a sync point which isn't there right now
1338  libmesh_parallel_only(comm());
1339 
1340  const auto & it = _registered_ray_map.find(name);
1341  if (it != _registered_ray_map.end())
1342  return it->second;
1343 
1344  const auto id = _reverse_registered_ray_map.size();
1345  _registered_ray_map.emplace(name, id);
1346  _reverse_registered_ray_map.push_back(name);
1347  return id;
1348 }
std::vector< std::string > & _reverse_registered_ray_map
Map from registered Ray ID to name.
const Parallel::Communicator & comm() const
virtual const std::string & name() const
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
void mooseError(Args &&... args) const
std::unordered_map< std::string, RayID > & _registered_ray_map
Map from registered Ray name to ID.
const bool _use_ray_registration
Whether or not to use Ray registration.

◆ registerRayAuxData() [1/2]

RayDataIndex RayTracingStudy::registerRayAuxData ( const std::string &  name)

Register a value to be filled in the aux data on a Ray with a given name.

Parameters
nameThe name to register
Returns
The Ray aux data index for the registered value

Note that this does not actually allocate the storage. It is simply a registration system to keep track of the values stored in the Ray aux data.

Definition at line 1098 of file RayTracingStudy.C.

Referenced by RayTracingStudyTest::RayTracingStudyTest(), StationaryRayStudyTest::StationaryRayStudyTest(), TestRayDataStudy::TestRayDataStudy(), and TestRayLots::TestRayLots().

1099 {
1100  return registerRayDataInternal(name, /* aux = */ true);
1101 }
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.
virtual const std::string & name() const

◆ registerRayAuxData() [2/2]

std::vector< RayDataIndex > RayTracingStudy::registerRayAuxData ( const std::vector< std::string > &  names)

Register values to be filled in the aux data on a Ray with a given name.

Parameters
namesThe names to register
Returns
The Ray aux data indices for the registered values

Note that this does not actually allocate the storage. It is simply a registration system to keep track of the values stored in the Ray aux data.

Definition at line 1104 of file RayTracingStudy.C.

1105 {
1106  return registerRayDataInternal(names, /* aux = */ true);
1107 }
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.

◆ registerRayData() [1/2]

RayDataIndex RayTracingStudy::registerRayData ( const std::string &  name)

Register a value to be filled in the data on a Ray with a given name.

Parameters
nameThe name to register
Returns
The Ray data index for the registered value

Note that this does not actually allocate the storage. It is simply a registration system to keep track of the values stored in the Ray data.

Definition at line 1067 of file RayTracingStudy.C.

Referenced by RayTracingStudyTest::generateRays(), RayTracingStudyTest::RayTracingStudyTest(), StationaryRayStudyTest::StationaryRayStudyTest(), TestRayDataStudy::TestRayDataStudy(), and TestRayLots::TestRayLots().

1068 {
1069  return registerRayDataInternal(name, /* aux = */ false);
1070 }
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.
virtual const std::string & name() const

◆ registerRayData() [2/2]

std::vector< RayDataIndex > RayTracingStudy::registerRayData ( const std::vector< std::string > &  names)

Register values to be filled in the data on a Ray with a given name.

Parameters
namesThe names to register
Returns
The Ray data indices for the registered value

Note that this does not actually allocate the storage. It is simply a registration system to keep track of the values stored in the Ray data.

Definition at line 1073 of file RayTracingStudy.C.

1074 {
1075  return registerRayDataInternal(names, /* aux = */ false);
1076 }
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.

◆ registerRayDataInternal() [1/2]

RayDataIndex RayTracingStudy::registerRayDataInternal ( const std::string &  name,
const bool  aux 
)
private

Internal method for registering Ray data or Ray aux data with a name.

Definition at line 975 of file RayTracingStudy.C.

Referenced by registerRayAuxData(), registerRayData(), and registerRayDataInternal().

976 {
977  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
978 
980  mooseError("Cannot register Ray ", (aux ? "aux " : ""), "data after initialSetup()");
981 
982  auto & map = aux ? _ray_aux_data_map : _ray_data_map;
983  const auto find = map.find(name);
984  if (find != map.end())
985  return find->second;
986 
987  auto & other_map = aux ? _ray_data_map : _ray_aux_data_map;
988  if (other_map.find(name) != other_map.end())
989  mooseError("Cannot register Ray aux data with name ",
990  name,
991  " because Ray ",
992  (aux ? "(non-aux)" : "aux"),
993  " data already exists with said name.");
994 
995  // Add into the name -> index map
996  map.emplace(name, map.size());
997 
998  // Add into the index -> names vector
999  auto & vector = aux ? _ray_aux_data_names : _ray_data_names;
1000  vector.push_back(name);
1001 
1002  return map.size() - 1;
1003 }
if(subdm)
virtual const std::string & name() const
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.
std::unordered_map< std::string, RayDataIndex > _ray_aux_data_map
The map from Ray aux data names to index.
std::unordered_map< std::string, RayDataIndex > _ray_data_map
The map from Ray data names to index.
bool _called_initial_setup
Whether or not we&#39;ve called initial setup - used to stop from late registration.
void mooseError(Args &&... args) const
std::vector< std::string > _ray_data_names
The names for each Ray data entry.

◆ registerRayDataInternal() [2/2]

std::vector< RayDataIndex > RayTracingStudy::registerRayDataInternal ( const std::vector< std::string > &  names,
const bool  aux 
)
private

Internal method for registering Ray data or Ray aux data with names.

Definition at line 1006 of file RayTracingStudy.C.

1007 {
1008  std::vector<RayDataIndex> indices(names.size());
1009  for (std::size_t i = 0; i < names.size(); ++i)
1010  indices[i] = registerRayDataInternal(names[i], aux);
1011  return indices;
1012 }
RayDataIndex registerRayDataInternal(const std::string &name, const bool aux)
Internal method for registering Ray data or Ray aux data with a name.

◆ reinitSegment()

void RayTracingStudy::reinitSegment ( const Elem elem,
const Point start,
const Point end,
const Real  length,
THREAD_ID  tid 
)
virtual

Reinitialize objects for a Ray segment for ray tracing.

Parameters
elemThe elem the segment is in
startStart point of the segment
endEnd point of the segment
lengthThe length of the start -> end segment
tidThread id

Definition at line 674 of file RayTracingStudy.C.

Referenced by TraceRay::onSegment().

676 {
677  mooseAssert(MooseUtils::absoluteFuzzyEqual((start - end).norm(), length), "Invalid length");
678  mooseAssert(currentlyPropagating(), "Should not call while not propagating");
679 
681 
682  // If we have any variables or material properties that are active, we definitely need to reinit
683  bool reinit = _fe_problem.hasActiveElementalMooseVariables(tid) ||
685  // If not, make sure that the RayKernels have not requested a reinit (this could happen when a
686  // RayKernel doesn't have variables or materials but still does an integration and needs qps)
687  if (!reinit)
688  for (const RayKernelBase * rk : currentRayKernels(tid))
689  if (rk->needSegmentReinit())
690  {
691  reinit = true;
692  break;
693  }
694 
695  if (reinit)
696  {
697  _fe_problem.prepare(elem, tid);
698 
699  std::vector<Point> points;
700  std::vector<Real> weights;
701  buildSegmentQuadrature(start, end, length, points, weights);
702  _fe_problem.reinitElemPhys(elem, points, tid);
703  _fe_problem.assembly(tid, _sys.number()).modifyArbitraryWeights(weights);
704 
706  }
707 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
Base object for the RayKernel syntax.
Definition: RayKernelBase.h:27
const std::vector< RayKernelBase * > & currentRayKernels(THREAD_ID tid) const
Gets the current RayKernels for a thread, which are set in segmentSubdomainSetup() ...
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
SystemBase & _sys
unsigned int number() const
auto norm(const T &a) -> decltype(std::abs(a))
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
subdomain_id_type subdomain_id() const
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
FEProblemBase & _fe_problem
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 bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
bool hasActiveMaterialProperties(const THREAD_ID tid) const
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid) override

◆ reserveRayBuffer()

void RayTracingStudy::reserveRayBuffer ( const std::size_t  size)
protected

Reserve size entires in the Ray buffer.

This can only be used within generateRays() and should be used when possible to reserve entires in the buffer before adding Rays via moveRay(s)ToBuffer.

Definition at line 1541 of file RayTracingStudy.C.

Referenced by RepeatableRayStudyBase::generateRays(), ViewFactorRayStudy::generateRays(), and RayTracingStudyTest::RayTracingStudyTest().

1542 {
1543  if (!currentlyGenerating())
1544  mooseError("Can only reserve in Ray buffer during generateRays()");
1545 
1546  _parallel_ray_study->reserveBuffer(size);
1547 }
bool currentlyGenerating() const
Whether or not the study is generating.
const std::unique_ptr< ParallelRayStudy > _parallel_ray_study
The study that used is to actually execute (trace) the Rays.
void mooseError(Args &&... args) const

◆ resetReplicatedRayIDs()

void RayTracingStudy::resetReplicatedRayIDs ( )
protected

Resets the generation of unique replicated RayIDs accessed via generateReplicatedRayID().

Definition at line 1637 of file RayTracingStudy.C.

Referenced by RayTracingStudy().

1638 {
1639  libmesh_parallel_only(comm());
1640 
1641  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1642 
1643  mooseAssert(!currentlyGenerating() && !currentlyPropagating(),
1644  "Cannot be reset during generation or propagation");
1645 
1647 }
bool currentlyGenerating() const
Whether or not the study is generating.
const Parallel::Communicator & comm() const
RayID _replicated_next_ray_id
Storage for the next available replicated RayID, obtained via generateReplicatedRayID() ...
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)

◆ resetUniqueRayIDs()

void RayTracingStudy::resetUniqueRayIDs ( )
protected

Resets the generation of unique RayIDs via generateUniqueRayID() to the beginning of the range.

Definition at line 1611 of file RayTracingStudy.C.

Referenced by RayTracingStudy().

1612 {
1613  libmesh_parallel_only(comm());
1614 
1615  Threads::spin_mutex::scoped_lock lock(_spin_mutex);
1616 
1617  mooseAssert(!currentlyGenerating() && !currentlyPropagating(),
1618  "Cannot be reset during generation or propagation");
1619 
1620  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
1622 }
bool currentlyGenerating() const
Whether or not the study is generating.
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
unsigned int n_threads()
const Parallel::Communicator & comm() const
std::vector< RayID > _threaded_next_ray_id
Storage for the next available unique RayID, obtained via generateUniqueRayID()
Threads::spin_mutex _spin_mutex
Spin mutex object for locks.
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once) ...
unsigned int THREAD_ID

◆ residualSetup()

void RayTracingStudy::residualSetup ( )
overridevirtual

Reimplemented from GeneralUserObject.

Definition at line 269 of file RayTracingStudy.C.

270 {
271  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
272  mooseAssert(_num_cached[tid] == 0, "Cached residuals/Jacobians not empty");
273 
274  for (auto & rto : getRayTracingObjects())
275  rto->residualSetup();
276 }
unsigned int n_threads()
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.
std::vector< std::size_t > _num_cached
Number of currently cached objects for Jacobian/residual for each thread.
unsigned int THREAD_ID

◆ sameLevelActiveElems()

bool RayTracingStudy::sameLevelActiveElems ( ) const
protected

Determine whether or not the mesh currently has active elements that are all the same level.

Definition at line 1573 of file RayTracingStudy.C.

Referenced by meshChanged().

1574 {
1575  unsigned int min_level = std::numeric_limits<unsigned int>::max();
1576  unsigned int max_level = std::numeric_limits<unsigned int>::min();
1577 
1578  for (const auto & elem : *_mesh.getActiveLocalElementRange())
1579  {
1580  const auto level = elem->level();
1581  min_level = std::min(level, min_level);
1582  max_level = std::max(level, max_level);
1583  }
1584 
1585  _communicator.min(min_level);
1586  _communicator.max(max_level);
1587 
1588  return min_level == max_level;
1589 }
libMesh::ConstElemRange * getActiveLocalElementRange()
MooseMesh & _mesh
The Mesh.
const Parallel::Communicator & _communicator
void min(const T &r, T &o, Request &req) const
void max(const T &r, T &o, Request &req) const

◆ segmentsOnCacheTraces()

bool RayTracingStudy::segmentsOnCacheTraces ( ) const
inline

Whether or not to cache individual element segments when _cache_traces = true.

Definition at line 577 of file RayTracingStudy.h.

Referenced by RayTracingMeshOutput::buildSegmentMesh(), RayTracingMeshOutput::neededNodes(), TraceRay::onContinueTrace(), TraceRay::onTrajectoryChanged(), RayTracingMeshOutput::RayTracingMeshOutput(), and RayTracingMeshOutput::startingIDs().

577 { return _segments_on_cache_traces; }
const bool _segments_on_cache_traces
Whether or not to cache individual element segments when caching.

◆ segmentSubdomainSetup()

void RayTracingStudy::segmentSubdomainSetup ( const SubdomainID  subdomain,
const THREAD_ID  tid,
const RayID  ray_id 
)
virtual

Setup for on subdomain change or subdomain AND ray change during ray tracing.

Parameters
subdomainThe subdomain changed to
tidThread id
ray_idID of the ray initiating the change

Definition at line 639 of file RayTracingStudy.C.

Referenced by TraceRay::onSubdomainChanged().

642 {
643  mooseAssert(currentlyPropagating(), "Should not call while not propagating");
644 
645  // Call subdomain setup on FE
646  _fe_problem.subdomainSetup(subdomain, tid);
647 
648  std::set<MooseVariableFEBase *> needed_moose_vars;
649  std::unordered_set<unsigned int> needed_mat_props;
650 
651  // Get RayKernels and their dependencies and call subdomain setup
652  getRayKernels(_threaded_current_ray_kernels[tid], subdomain, tid, ray_id);
653  for (auto & rkb : _threaded_current_ray_kernels[tid])
654  {
655  rkb->subdomainSetup();
656 
657  const auto & mv_deps = rkb->getMooseVariableDependencies();
658  needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
659 
660  const auto & mp_deps = rkb->getMatPropDependencies();
661  needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
662  }
663 
664  // Prepare aux vars
665  for (auto & var : needed_moose_vars)
666  if (var->kind() == Moose::VarKindType::VAR_AUXILIARY)
667  var->prepareAux();
668 
669  _fe_problem.setActiveElementalMooseVariables(needed_moose_vars, tid);
670  _fe_problem.prepareMaterials(needed_mat_props, subdomain, tid);
671 }
void getRayKernels(std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.
std::vector< std::vector< RayKernelBase * > > _threaded_current_ray_kernels
The current RayKernel objects for each thread.
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase * > &moose_vars, const THREAD_ID tid) override
bool currentlyPropagating() const
Whether or not the study is propagating (tracing Rays)
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
FEProblemBase & _fe_problem
void prepareMaterials(const std::unordered_set< unsigned int > &consumer_needed_mat_props, const SubdomainID blk_id, const THREAD_ID tid)

◆ shouldCacheTrace()

virtual bool RayTracingStudy::shouldCacheTrace ( const std::shared_ptr< Ray > &  ) const
inlinevirtual

Virtual that allows for selection in if a Ray should be cached or not (only used when _cache_traces).

Definition at line 583 of file RayTracingStudy.h.

Referenced by initThreadedCachedTrace(), and TraceRay::trace().

584  {
585  return _always_cache_traces;
586  }
bool _always_cache_traces
Whether or not to cache traces on every trace execution.

◆ sideIsIncoming()

bool RayTracingStudy::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.

Definition at line 1656 of file RayTracingStudy.C.

Referenced by TraceRay::findExternalBoundarySide(), TraceRay::onSegment(), ClaimRays::postClaimRay(), and TraceRay::trace().

1660 {
1661  const auto & normal = getSideNormal(elem, side, tid);
1662  const auto dot = normal * direction;
1663  return dot < TraceRayTools::TRACE_TOLERANCE;
1664 }
const Real TRACE_TOLERANCE
The standard tolerance to use in tracing.
Definition: TraceRayTools.h:48
virtual const Point & getSideNormal(const Elem *elem, const unsigned short side, const THREAD_ID tid)
Get the outward normal for a given element side.

◆ sideIsNonPlanar()

bool RayTracingStudy::sideIsNonPlanar ( const Elem *  elem,
const unsigned short  s 
) const
inline

Whether or not the side on elem elem is non-planar.

This is cached because checking whether or not a face is planar is costly

Definition at line 465 of file RayTracingStudy.h.

Referenced by TraceRay::exitsElem(), ViewFactorRayStudy::generateRays(), ReflectRayBC::onBoundary(), TraceRay::onSegment(), TraceRay::possiblyAddToBoundaryElems(), Ray::setStart(), and TraceRay::trace().

466  {
468  }
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...
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
ElemIndexHelper _elem_index_helper
Helper for defining a local contiguous index for each element.
bool _has_non_planar_sides
Whether or not the local mesh has elements with non-planar sides.

◆ subdomainHmax()

Real RayTracingStudy::subdomainHmax ( const SubdomainID  subdomain_id) const

Get the cached hmax for all elements in a subdomain.

Used for scaling tolerances in ray tracing.

Definition at line 1592 of file RayTracingStudy.C.

Referenced by RayTracingStudyTest::generateRays(), TraceRay::onSubdomainChanged(), TraceRay::subdomainHmax(), and subdomainHMaxSetup().

1593 {
1594  const auto find = _subdomain_hmax.find(subdomain_id);
1595  if (find == _subdomain_hmax.end())
1596  mooseError("Subdomain ", subdomain_id, " not found in subdomain hmax map");
1597  return find->second;
1598 }
std::unordered_map< SubdomainID, Real > _subdomain_hmax
The cached hmax for all elements in a subdomain.
void mooseError(Args &&... args) const

◆ subdomainHMaxSetup()

void RayTracingStudy::subdomainHMaxSetup ( )
private

Caches the hmax for all elements in each subdomain.

Definition at line 513 of file RayTracingStudy.C.

Referenced by initialSetup(), and meshChanged().

514 {
515  // Setup map with subdomain keys
516  _subdomain_hmax.clear();
517  for (const auto subdomain_id : _mesh.meshSubdomains())
518  _subdomain_hmax[subdomain_id] = std::numeric_limits<Real>::min();
519 
520  // Set local max for each subdomain
521  for (const auto & elem : *_mesh.getActiveLocalElementRange())
522  {
523  auto & entry = _subdomain_hmax.at(elem->subdomain_id());
524  entry = std::max(entry, elem->hmax());
525  }
526 
527  // Accumulate global max for each subdomain
529 
530  if (getParam<bool>("warn_subdomain_hmax"))
531  {
532  const auto warn_prefix = type() + " '" + name() + "': ";
533  const auto warn_suffix =
534  "\n\nRay tracing uses an approximate element size for each subdomain to scale the\n"
535  "tolerances used in computing ray intersections. This warning suggests that the\n"
536  "approximate element size is not a good approximation. This is likely due to poor\n"
537  "element aspect ratios.\n\n"
538  "This warning is only output for the first element affected.\n"
539  "To disable this warning, set warn_subdomain_hmax = false.\n";
540 
541  for (const auto & elem : *_mesh.getActiveLocalElementRange())
542  {
543  const auto hmin = elem->hmin();
544  const auto hmax = elem->hmax();
545  const auto max_hmax = subdomainHmax(elem->subdomain_id());
546 
547  const auto hmax_rel = hmax / max_hmax;
548  if (hmax_rel < 1.e-2 || hmax_rel > 1.e2)
549  mooseDoOnce(mooseWarning(warn_prefix,
550  "Element hmax varies significantly from subdomain hmax.\n",
551  warn_suffix,
552  "First element affected:\n",
553  Moose::stringify(*elem)););
554 
555  const auto h_rel = max_hmax / hmin;
556  if (h_rel > 1.e2)
557  mooseDoOnce(mooseWarning(warn_prefix,
558  "Element hmin varies significantly from subdomain hmax.\n",
559  warn_suffix,
560  "First element affected:\n",
561  Moose::stringify(*elem)););
562  }
563  }
564 }
libMesh::ConstElemRange * getActiveLocalElementRange()
MooseMesh & _mesh
The Mesh.
std::unordered_map< SubdomainID, Real > _subdomain_hmax
The cached hmax for all elements in a subdomain.
const Parallel::Communicator & _communicator
virtual const std::string & name() const
void mooseWarning(Args &&... args) const
Real subdomainHmax(const SubdomainID subdomain_id) const
Get the cached hmax for all elements in a subdomain.
const std::string & type() const
std::string stringify(const T &t)
void max(const T &r, T &o, Request &req) const
const std::set< SubdomainID > & meshSubdomains() const

◆ timestepSetup()

void RayTracingStudy::timestepSetup ( )
overridevirtual

Reimplemented from GeneralUserObject.

Definition at line 289 of file RayTracingStudy.C.

290 {
291  for (auto & rto : getRayTracingObjects())
292  rto->timestepSetup();
293 }
std::vector< RayTracingObject * > getRayTracingObjects()
Gets all of the currently active RayTracingObjects.

◆ tolerateFailure()

bool RayTracingStudy::tolerateFailure ( ) const
inline

Whether or not to tolerate failure.

Definition at line 209 of file RayTracingStudy.h.

Referenced by TraceRay::exitsElem(), TraceRay::onBoundary(), and TraceRay::trace().

209 { return _tolerate_failure; }
const bool _tolerate_failure
Whether or not to tolerate a Ray Tracing failure.

◆ totalDistance()

Real RayTracingStudy::totalDistance ( ) const
inline

Total distance traveled by all Rays.

Definition at line 172 of file RayTracingStudy.h.

Referenced by RayTracingStudyResult::getValue().

172 { return _total_distance; }
Real _total_distance
Total distance traveled by all Rays.

◆ totalIntersections()

unsigned long long int RayTracingStudy::totalIntersections ( ) const
inline

Total number of Ray/element intersections.

Definition at line 155 of file RayTracingStudy.h.

155 { return _total_intersections; }
unsigned long long int _total_intersections
Total number of Ray/element intersections.

◆ totalProcessorCrossings()

unsigned long long int RayTracingStudy::totalProcessorCrossings ( ) const
inline

Total number of processor crossings.

Definition at line 138 of file RayTracingStudy.h.

Referenced by RayTracingStudyResult::getValue().

138 { return _total_processor_crossings; }
unsigned long long int _total_processor_crossings
Total number of processor crossings.

◆ totalVolume()

Real RayTracingStudy::totalVolume ( ) const
inline

Get the current total volume of the domain.

Definition at line 437 of file RayTracingStudy.h.

Referenced by isRectangularDomain().

437 { return _total_volume; }
Real _total_volume
The total volume of the domain.

◆ traceableMeshChecks()

void RayTracingStudy::traceableMeshChecks ( )
private

Check for if all of the element types in the mesh are supported by ray tracing.

Definition at line 384 of file RayTracingStudy.C.

Referenced by initialSetup().

385 {
386 
387  for (const auto & elem : *_mesh.getActiveLocalElementRange())
388  {
389  if (_fe_problem.adaptivity().isOn())
390  {
392  mooseError("Element type ",
393  Utility::enum_to_string(elem->type()),
394  " is not supported in ray tracing with adaptivity");
395  }
396  else if (!TraceRayTools::isTraceableElem(elem))
397  mooseError("Element type ",
398  Utility::enum_to_string(elem->type()),
399  " is not supported in ray tracing");
400  }
401 }
libMesh::ConstElemRange * getActiveLocalElementRange()
MooseMesh & _mesh
The Mesh.
bool isTraceableElem(const Elem *elem)
bool isAdaptivityTraceableElem(const Elem *elem)
bool isOn()
FEProblemBase & _fe_problem
void mooseError(Args &&... args) const
Adaptivity & adaptivity()

◆ traceRay() [1/2]

TraceRay& RayTracingStudy::traceRay ( const THREAD_ID  tid)
inline

Gets the threaded TraceRay object for tid.

Definition at line 647 of file RayTracingStudy.h.

Referenced by BackfaceCullingStudyTest::BackfaceCullingStudyTest().

647 { return *_threaded_trace_ray[tid]; }
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)

◆ traceRay() [2/2]

const TraceRay& RayTracingStudy::traceRay ( const THREAD_ID  tid) const
inline

Definition at line 648 of file RayTracingStudy.h.

648 { return *_threaded_trace_ray[tid]; }
std::vector< std::shared_ptr< TraceRay > > _threaded_trace_ray
The TraceRay objects for each thread (they do the physical tracing)

◆ useRayRegistration()

bool RayTracingStudy::useRayRegistration ( ) const
inline

Whether or not ray registration is being used.

Definition at line 564 of file RayTracingStudy.h.

Referenced by Ray::getInfo(), RayIntegralValue::initialize(), and RayDataValue::RayDataValue().

564 { return _use_ray_registration; }
const bool _use_ray_registration
Whether or not to use Ray registration.

◆ validParams()

InputParameters RayTracingStudy::validParams ( )
static

Whether or not subdomain setup is dependent on the Ray

Definition at line 33 of file RayTracingStudy.C.

Referenced by StationaryRayStudyTest::validParams(), TestRay::validParams(), RayTracingStudyTest::validParams(), TestPICRayStudy::validParams(), ViewFactorRayStudy::validParams(), TestReuseRaysStudy::validParams(), TestTransientRaysStudy::validParams(), RepeatableRayStudyBase::validParams(), RayTracingStudyNoBankingTest::validParams(), and RayTracingStudyWithRegistrationTest::validParams().

34 {
35  auto params = GeneralUserObject::validParams();
36 
37  // Parameters for the execution of the rays
39 
40  params.addRangeCheckedParam<Real>("ray_distance",
41  std::numeric_limits<Real>::max(),
42  "ray_distance > 0",
43  "The maximum distance all Rays can travel");
44 
45  params.addParam<bool>(
46  "tolerate_failure", false, "Whether or not to tolerate a ray tracing failure");
47 
48  MooseEnum work_buffers("lifo circular", "circular");
49  params.addParam<MooseEnum>("work_buffer_type", work_buffers, "The work buffer type to use");
50 
51  params.addParam<bool>(
52  "ray_kernel_coverage_check", true, "Whether or not to perform coverage checks on RayKernels");
53  params.addParam<bool>("warn_non_planar",
54  true,
55  "Whether or not to produce a warning if any element faces are non-planar.");
56 
57  params.addParam<bool>(
58  "always_cache_traces",
59  false,
60  "Whether or not to cache the Ray traces on every execution, primarily for use in output. "
61  "Warning: this can get expensive very quick with a large number of rays!");
62  params.addParam<bool>("data_on_cache_traces",
63  false,
64  "Whether or not to also cache the Ray's data when caching its traces");
65  params.addParam<bool>("aux_data_on_cache_traces",
66  false,
67  "Whether or not to also cache the Ray's aux data when caching its traces");
68  params.addParam<bool>(
69  "segments_on_cache_traces",
70  true,
71  "Whether or not to cache individual segments when trace caching is enabled. If false, we "
72  "will instead cache a segment for each part of the trace where the direction is the same. "
73  "This minimizes the number of segments requied to represent the Ray's path, but removes the "
74  "ability to show Ray field data on each segment through an element.");
75 
76  params.addParam<bool>("use_internal_sidesets",
77  false,
78  "Whether or not to use internal sidesets for RayBCs in ray tracing");
79 
80  params.addParam<bool>("warn_subdomain_hmax",
81  true,
82  "Whether or not to warn if the approximated hmax (constant on subdomain) "
83  "varies significantly for an element");
84 
85  params.addParam<bool>(
86  "verify_rays",
87  true,
88  "Whether or not to verify the generated Rays. This includes checking their "
89  "starting information and the uniqueness of Rays before and after execution. This is also "
90  "used by derived studies for more specific verification.");
91  params.addParam<bool>("verify_trace_intersections",
92  true,
93  "Whether or not to verify the trace intersections in devel and dbg modes. "
94  "Trace intersections are not verified regardless of this parameter in "
95  "optimized modes (opt, oprof).");
96 
97  params.addParam<bool>("allow_other_flags_with_prekernels",
98  false,
99  "Whether or not to allow the list of execution flags to have PRE_KERNELS "
100  "mixed with other flags. If this parameter is not set then if PRE_KERNELS "
101  "is provided it must be the only execution flag.");
102 
103  ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
104  exec_enum.addAvailableFlags(EXEC_PRE_KERNELS);
105 
106  params.addParamNamesToGroup(
107  "always_cache_traces data_on_cache_traces aux_data_on_cache_traces segments_on_cache_traces",
108  "Trace cache");
109  params.addParamNamesToGroup("warn_non_planar warn_subdomain_hmax", "Tracing Warnings");
110  params.addParamNamesToGroup("ray_kernel_coverage_check verify_rays verify_trace_intersections",
111  "Checks and verifications");
112 
113  // Whether or not each Ray must be registered using the registerRay() API
114  params.addPrivateParam<bool>("_use_ray_registration", true);
115  // Whether or not to bank Rays on completion
116  params.addPrivateParam<bool>("_bank_rays_on_completion", true);
118  params.addPrivateParam<bool>("_ray_dependent_subdomain_setup", true);
119 
120  // Add a point neighbor relationship manager
121  params.addRelationshipManager("ElementPointNeighborLayers",
124  [](const InputParameters &, InputParameters & rm_params)
125  { rm_params.set<unsigned short>("layers") = 1; });
126 
127  return params;
128 }
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ verifyDependenciesExist()

void RayTracingStudy::verifyDependenciesExist ( const std::vector< RayTracingObject *> &  rtos)
private

Verifies that the dependencies exist for a set of RayTracingObjects.

Definition at line 360 of file RayTracingStudy.C.

Referenced by dependencyChecks().

361 {
362  for (const auto & rto : rtos)
363  for (const auto & dep_name : rto->getRequestedItems())
364  {
365  bool found = false;
366  for (const auto & rto_search : rtos)
367  if (rto_search->name() == dep_name)
368  {
369  found = true;
370  break;
371  }
372 
373  if (!found)
374  rto->paramError("depends_on",
375  "The ",
376  rto->parameters().get<std::string>("_moose_base"),
377  " '",
378  dep_name,
379  "' does not exist");
380  }
381 }

◆ verifyRays()

bool RayTracingStudy::verifyRays ( ) const
inline

Whether or not to verify if Rays have valid information before being traced.

Definition at line 654 of file RayTracingStudy.h.

Referenced by RayKernelBase::changeRayStartDirection(), ClaimRays::claim(), RepeatableRayStudyBase::defineRaysInternal(), executeStudy(), Ray::setStart(), Ray::setStartingEndPoint(), and TraceRay::trace().

654 { return _verify_rays; }
const bool _verify_rays
Whether or not to verify if Rays have valid information before being traced.

◆ verifyTraceIntersections()

bool RayTracingStudy::verifyTraceIntersections ( ) const
inline

Whether or not trace verification is enabled in devel/dbg modes.

Definition at line 659 of file RayTracingStudy.h.

Referenced by TraceRay::exitsElem(), TraceRay::onSegment(), TraceRay::onTrajectoryChanged(), and TraceRay::trace().

659 { return _verify_trace_intersections; }
const bool _verify_trace_intersections
Whether or not to verify the trace intersections in devel and dbg modes.

◆ verifyUniqueRayIDs()

void RayTracingStudy::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.

Parameters
beginThe beginning of the range of Rays to check
endThe end of the range of Rays to check
globalIf true, this will complete the verification across all processors
error_suffixEntry point for additional information in the error message

Definition at line 1419 of file RayTracingStudy.C.

Referenced by executeStudy(), and RepeatableRayStudyBase::verifyReplicatedRays().

1423 {
1424  // Determine the unique set of Ray IDs on this processor,
1425  // and if not locally unique throw an error. Once we build this set,
1426  // we will send it to rank 0 to verify globally
1427  std::set<RayID> local_rays;
1428  for (const std::shared_ptr<Ray> & ray : as_range(begin, end))
1429  {
1430  mooseAssert(ray, "Null ray");
1431 
1432  // Try to insert into the set; the second entry in the pair
1433  // will be false if it was not inserted
1434  if (!local_rays.insert(ray->id()).second)
1435  {
1436  for (const std::shared_ptr<Ray> & other_ray : as_range(begin, end))
1437  if (ray.get() != other_ray.get() && ray->id() == other_ray->id())
1438  mooseError("Multiple Rays exist with ID ",
1439  ray->id(),
1440  " on processor ",
1441  _pid,
1442  " ",
1443  error_suffix,
1444  "\n\nOffending Ray information:\n\n",
1445  ray->getInfo(),
1446  "\n",
1447  other_ray->getInfo());
1448  }
1449  }
1450 
1451  // Send IDs from all procs to rank 0 and verify on rank 0
1452  if (global)
1453  {
1454  // Package our local IDs and send to rank 0
1455  std::map<processor_id_type, std::vector<RayID>> send_ids;
1456  if (local_rays.size())
1457  send_ids.emplace(std::piecewise_construct,
1458  std::forward_as_tuple(0),
1459  std::forward_as_tuple(local_rays.begin(), local_rays.end()));
1460  local_rays.clear();
1461 
1462  // Mapping on rank 0 from ID -> processor ID
1463  std::map<RayID, processor_id_type> global_map;
1464 
1465  // Verify another processor's IDs against the global map on rank 0
1466  const auto check_ids =
1467  [this, &global_map, &error_suffix](processor_id_type pid, const std::vector<RayID> & ids)
1468  {
1469  for (const RayID id : ids)
1470  {
1471  const auto emplace_pair = global_map.emplace(id, pid);
1472 
1473  // Means that this ID already exists in the map
1474  if (!emplace_pair.second)
1475  mooseError("Ray with ID ",
1476  id,
1477  " exists on ranks ",
1478  emplace_pair.first->second,
1479  " and ",
1480  pid,
1481  "\n",
1482  error_suffix);
1483  }
1484  };
1485 
1486  Parallel::push_parallel_vector_data(_communicator, send_ids, check_ids);
1487  }
1488 }
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
const Parallel::Communicator & _communicator
uint8_t processor_id_type
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
void mooseError(Args &&... args) const
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once) ...

◆ verifyUniqueRays()

void RayTracingStudy::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.

That is, that there are not multiple shared_ptrs that point to the same Ray

Parameters
beginThe beginning of the range of Rays to check
endThe end of the range of Rays to check
error_suffixEntry point for additional information in the error message

Definition at line 1491 of file RayTracingStudy.C.

Referenced by executeStudy().

1494 {
1495  std::set<const Ray *> rays;
1496  for (const std::shared_ptr<Ray> & ray : as_range(begin, end))
1497  if (!rays.insert(ray.get()).second) // false if not inserted into rays
1498  mooseError("Multiple shared_ptrs were found that point to the same Ray ",
1499  error_suffix,
1500  "\n\nOffending Ray:\n",
1501  ray->getInfo());
1502 }
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
void mooseError(Args &&... args) const

◆ warnNonPlanar()

bool RayTracingStudy::warnNonPlanar ( ) const
inline

Whether or not to produce a warning when interacting with a non-planar mesh.

Definition at line 673 of file RayTracingStudy.h.

673 { return _warn_non_planar; }
const bool _warn_non_planar
Whether not to warn if non-planar faces are found.

◆ zeroAuxVariables()

void RayTracingStudy::zeroAuxVariables ( )
private

Zero the AuxVariables that the registered AuxRayKernels contribute to.

Definition at line 621 of file RayTracingStudy.C.

Referenced by executeStudy().

622 {
623  std::set<std::string> vars_to_be_zeroed;
624  std::vector<RayKernelBase *> ray_kernels;
625  getRayKernels(ray_kernels, 0);
626  for (auto & rk : ray_kernels)
627  {
628  AuxRayKernel * aux_rk = dynamic_cast<AuxRayKernel *>(rk);
629  if (aux_rk)
630  vars_to_be_zeroed.insert(aux_rk->variable().name());
631  }
632 
633  std::vector<std::string> vars_to_be_zeroed_vec(vars_to_be_zeroed.begin(),
634  vars_to_be_zeroed.end());
635  _fe_problem.getAuxiliarySystem().zeroVariables(vars_to_be_zeroed_vec);
636 }
void getRayKernels(std::vector< RayKernelBase *> &result, SubdomainID id, THREAD_ID tid)
Fills the active RayKernels associated with this study and a block into result.
const std::string & name() const override
MooseVariableFE< Real > & variable()
Gets the variable this AuxRayKernel contributes to.
Definition: AuxRayKernel.h:38
AuxiliarySystem & getAuxiliarySystem()
FEProblemBase & _fe_problem
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)

Member Data Documentation

◆ _always_cache_traces

bool RayTracingStudy::_always_cache_traces
protected

Whether or not to cache traces on every trace execution.

Definition at line 883 of file RayTracingStudy.h.

Referenced by shouldCacheTrace().

◆ _aux_data_on_cache_traces

const bool RayTracingStudy::_aux_data_on_cache_traces
protected

Whether or not to store the Ray aux data on the cache traces.

Definition at line 887 of file RayTracingStudy.h.

Referenced by auxDataOnCacheTraces().

◆ _b_box

libMesh::BoundingBox RayTracingStudy::_b_box
private

Nodal bounding box for the domain.

Definition at line 1060 of file RayTracingStudy.h.

Referenced by boundingBox(), isRectangularDomain(), and RayTracingStudy().

◆ _bank_rays_on_completion

const bool RayTracingStudy::_bank_rays_on_completion
protected

Whether or not to bank rays on completion.

Definition at line 878 of file RayTracingStudy.h.

Referenced by bankRaysOnCompletion(), onCompleteRay(), and rayBank().

◆ _cached_traces

std::vector<TraceData> RayTracingStudy::_cached_traces
private

Storage for the cached traces.

Definition at line 1040 of file RayTracingStudy.h.

Referenced by executeStudy(), and getCachedTraces().

◆ _called_initial_setup

bool RayTracingStudy::_called_initial_setup
private

Whether or not we've called initial setup - used to stop from late registration.

Definition at line 1132 of file RayTracingStudy.h.

Referenced by executeStudy(), getRayBCs(), getRayKernels(), initialSetup(), and registerRayDataInternal().

◆ _comm

const Parallel::Communicator& RayTracingStudy::_comm
protected

The Communicator.

Definition at line 863 of file RayTracingStudy.h.

Referenced by LotsOfRaysRayStudy::defineRays().

◆ _data_on_cache_traces

const bool RayTracingStudy::_data_on_cache_traces
protected

Whether or not to store the Ray data on the cache traces.

Definition at line 885 of file RayTracingStudy.h.

Referenced by dataOnCacheTraces().

◆ _domain_max_length

Real RayTracingStudy::_domain_max_length
private

An inflated max distance for the domain.

Definition at line 1064 of file RayTracingStudy.h.

Referenced by domainMaxLength().

◆ _elem_index_helper

ElemIndexHelper RayTracingStudy::_elem_index_helper
private

Helper for defining a local contiguous index for each element.

Definition at line 1135 of file RayTracingStudy.h.

Referenced by internalSidesetSetup(), localElemIndexSetup(), nonPlanarSideSetup(), and sideIsNonPlanar().

◆ _ending_distance

Real RayTracingStudy::_ending_distance
private

Total distance traveled by Rays that end on this processor.

Definition at line 1121 of file RayTracingStudy.h.

Referenced by endingDistance(), executeStudy(), and onCompleteRay().

◆ _ending_intersections

unsigned long long int RayTracingStudy::_ending_intersections
private

Total number of Ray/element intersections for Rays that finished on this processor.

Definition at line 1108 of file RayTracingStudy.h.

Referenced by endingIntersections(), executeStudy(), and onCompleteRay().

◆ _ending_max_intersections

unsigned int RayTracingStudy::_ending_max_intersections
private

Max number of intersections for Rays that finished on this processor.

Definition at line 1110 of file RayTracingStudy.h.

Referenced by endingMaxIntersections(), executeStudy(), and onCompleteRay().

◆ _ending_max_processor_crossings

unsigned int RayTracingStudy::_ending_max_processor_crossings
private

Max number of total processor crossings for Rays that finished on this processor.

Definition at line 1101 of file RayTracingStudy.h.

Referenced by endingMaxProcessorCrossings(), executeStudy(), and onCompleteRay().

◆ _ending_max_trajectory_changes

unsigned int RayTracingStudy::_ending_max_trajectory_changes
private

Max number of trajectory changes for Rays that finished on this processor.

Definition at line 1112 of file RayTracingStudy.h.

Referenced by executeStudy(), and onCompleteRay().

◆ _ending_processor_crossings

unsigned long long int RayTracingStudy::_ending_processor_crossings
private

Total number of processor crossings for Rays that finished on this processor.

Definition at line 1099 of file RayTracingStudy.h.

Referenced by endingProcessorCrossings(), executeStudy(), and onCompleteRay().

◆ _execution_start_time

std::chrono::steady_clock::time_point RayTracingStudy::_execution_start_time
private

Timing.

Definition at line 1018 of file RayTracingStudy.h.

Referenced by executeStudy().

◆ _execution_time

std::chrono::steady_clock::duration RayTracingStudy::_execution_time
private

Definition at line 1019 of file RayTracingStudy.h.

Referenced by executeStudy(), executionTime(), and executionTimeNano().

◆ _generation_time

std::chrono::steady_clock::duration RayTracingStudy::_generation_time
private

Definition at line 1020 of file RayTracingStudy.h.

Referenced by executeStudy(), and generationTime().

◆ _has_non_planar_sides

bool RayTracingStudy::_has_non_planar_sides
private

Whether or not the local mesh has elements with non-planar sides.

Definition at line 1052 of file RayTracingStudy.h.

Referenced by nonPlanarSideSetup(), and sideIsNonPlanar().

◆ _has_same_level_active_elems

bool RayTracingStudy::_has_same_level_active_elems
private

Whether or not the mesh has active elements of the same level.

Definition at line 1057 of file RayTracingStudy.h.

Referenced by hasSameLevelActiveElems(), and meshChanged().

◆ _internal_sidesets

std::set<BoundaryID> RayTracingStudy::_internal_sidesets
private

The BoundaryIDs on the local mesh that have internal RayBCs.

Definition at line 1048 of file RayTracingStudy.h.

Referenced by getInternalSidesets(), hasInternalSidesets(), and internalSidesetSetup().

◆ _internal_sidesets_map

std::vector<std::vector<std::vector<BoundaryID> > > RayTracingStudy::_internal_sidesets_map
private

Internal sideset data, if internal sidesets exist (indexed with getLocalElemIndex())

Definition at line 1050 of file RayTracingStudy.h.

Referenced by internalSidesetSetup().

◆ _local_trace_ray_results

std::vector<unsigned long long int> RayTracingStudy::_local_trace_ray_results
private

Cumulative results on this processor from the threaded TraceRay objects.

Definition at line 1126 of file RayTracingStudy.h.

Referenced by executeStudy(), and localTraceRayResult().

◆ _loose_b_box

libMesh::BoundingBox RayTracingStudy::_loose_b_box
private

Loose nodal bounding box for the domain.

Definition at line 1062 of file RayTracingStudy.h.

Referenced by looseBoundingBox(), and RayTracingStudy().

◆ _max_intersections

unsigned int RayTracingStudy::_max_intersections
private

Max number of intersections for a single Ray.

Definition at line 1116 of file RayTracingStudy.h.

Referenced by executeStudy(), and maxIntersections().

◆ _max_processor_crossings

unsigned int RayTracingStudy::_max_processor_crossings
private

Max number of processor crossings for all Rays.

Definition at line 1105 of file RayTracingStudy.h.

Referenced by executeStudy(), and maxProcessorCrossings().

◆ _max_trajectory_changes

unsigned int RayTracingStudy::_max_trajectory_changes
private

Max number of trajectory changes for a single Ray.

Definition at line 1118 of file RayTracingStudy.h.

Referenced by executeStudy(), and maxTrajectoryChanges().

◆ _mesh

MooseMesh& RayTracingStudy::_mesh
protected

◆ _non_planar_sides

std::vector<std::vector<unsigned short> > RayTracingStudy::_non_planar_sides
private

Non planar side data, which is for quick checking if an elem side is non-planar We use unsigned short here to avoid a std::vector<bool>; 0 = false, otherwise true.

Definition at line 1055 of file RayTracingStudy.h.

Referenced by nonPlanarSideSetup(), and sideIsNonPlanar().

◆ _num_cached

std::vector<std::size_t> RayTracingStudy::_num_cached
private

Number of currently cached objects for Jacobian/residual for each thread.

Definition at line 1045 of file RayTracingStudy.h.

Referenced by executeStudy(), jacobianSetup(), postOnSegment(), and residualSetup().

◆ _parallel_ray_study

const std::unique_ptr<ParallelRayStudy> RayTracingStudy::_parallel_ray_study
private

◆ _pid

const processor_id_type RayTracingStudy::_pid
protected

◆ _propagation_time

std::chrono::steady_clock::duration RayTracingStudy::_propagation_time
private

Definition at line 1021 of file RayTracingStudy.h.

Referenced by executeStudy(), and propagationTime().

◆ _ray_aux_data_map

std::unordered_map<std::string, RayDataIndex> RayTracingStudy::_ray_aux_data_map
private

The map from Ray aux data names to index.

Definition at line 1027 of file RayTracingStudy.h.

Referenced by getRayDataIndexInternal(), and registerRayDataInternal().

◆ _ray_aux_data_names

std::vector<std::string> RayTracingStudy::_ray_aux_data_names
private

The names for each Ray aux data entry.

Definition at line 1032 of file RayTracingStudy.h.

Referenced by getRayDataNameInternal(), hasRayAuxData(), rayAuxDataNames(), rayAuxDataSize(), and registerRayDataInternal().

◆ _ray_bank

std::vector<std::shared_ptr<Ray> > RayTracingStudy::_ray_bank
private

Cumulative Ray bank - stored only when _bank_rays_on_completion.

Definition at line 1086 of file RayTracingStudy.h.

Referenced by executeStudy(), onCompleteRay(), and rayBank().

◆ _ray_data_map

std::unordered_map<std::string, RayDataIndex> RayTracingStudy::_ray_data_map
private

The map from Ray data names to index.

Definition at line 1025 of file RayTracingStudy.h.

Referenced by getRayDataIndexInternal(), and registerRayDataInternal().

◆ _ray_data_names

std::vector<std::string> RayTracingStudy::_ray_data_names
private

The names for each Ray data entry.

Definition at line 1030 of file RayTracingStudy.h.

Referenced by getRayDataNameInternal(), hasRayData(), rayDataNames(), rayDataSize(), and registerRayDataInternal().

◆ _ray_dependent_subdomain_setup

const bool RayTracingStudy::_ray_dependent_subdomain_setup
protected

Whether or not subdomain setup is dependent on the Ray.

Definition at line 880 of file RayTracingStudy.h.

Referenced by rayDependentSubdomainSetup().

◆ _ray_kernel_coverage_check

const bool RayTracingStudy::_ray_kernel_coverage_check
protected

Whether or not to perform coverage checks on RayKernels.

Definition at line 868 of file RayTracingStudy.h.

Referenced by coverageChecks().

◆ _ray_max_distance

const Real RayTracingStudy::_ray_max_distance
protected

Max distance a Ray can travel before being killed (can change)

Definition at line 891 of file RayTracingStudy.h.

Referenced by rayMaxDistance().

◆ _registered_ray_map

std::unordered_map<std::string, RayID>& RayTracingStudy::_registered_ray_map
private

Map from registered Ray name to ID.

Definition at line 1035 of file RayTracingStudy.h.

Referenced by registeredRayID(), registeredRaySetup(), and registerRay().

◆ _replicated_next_ray_id

RayID RayTracingStudy::_replicated_next_ray_id
private

Storage for the next available replicated RayID, obtained via generateReplicatedRayID()

Definition at line 1090 of file RayTracingStudy.h.

Referenced by generateReplicatedRayID(), and resetReplicatedRayIDs().

◆ _reverse_registered_ray_map

std::vector<std::string>& RayTracingStudy::_reverse_registered_ray_map
private

Map from registered Ray ID to name.

Definition at line 1037 of file RayTracingStudy.h.

Referenced by registeredRayName(), and registerRay().

◆ _segment_qrule

std::unique_ptr<libMesh::QBase> RayTracingStudy::_segment_qrule
private

Quadrature rule for laying points across a 1D ray segment.

Definition at line 1096 of file RayTracingStudy.h.

Referenced by buildSegmentQuadrature(), and initialSetup().

◆ _segments_on_cache_traces

const bool RayTracingStudy::_segments_on_cache_traces
protected

Whether or not to cache individual element segments when caching.

Definition at line 889 of file RayTracingStudy.h.

Referenced by segmentsOnCacheTraces().

◆ _spin_mutex

Threads::spin_mutex RayTracingStudy::_spin_mutex
mutableprivate

◆ _subdomain_hmax

std::unordered_map<SubdomainID, Real> RayTracingStudy::_subdomain_hmax
private

The cached hmax for all elements in a subdomain.

Definition at line 1129 of file RayTracingStudy.h.

Referenced by subdomainHmax(), and subdomainHMaxSetup().

◆ _threaded_cache_ray_bc

std::vector<TheWarehouse::QueryCache<AttribBoundaries> > RayTracingStudy::_threaded_cache_ray_bc
private

Threaded cached boundary query for RayBC objects pertaining to this study.

Definition at line 1071 of file RayTracingStudy.h.

Referenced by getRayBCs().

◆ _threaded_cache_ray_kernel

std::vector<TheWarehouse::QueryCache<AttribSubdomains> > RayTracingStudy::_threaded_cache_ray_kernel
private

Threaded cached subdomain query for RayKernelBase objects pertaining to this study.

Definition at line 1069 of file RayTracingStudy.h.

Referenced by getRayKernels().

◆ _threaded_cached_normals

std::vector<std::unordered_map<std::pair<const Elem *, unsigned short>, Point> > RayTracingStudy::_threaded_cached_normals
private

Threaded cache for side normals that have been computed already during tracing.

Definition at line 1084 of file RayTracingStudy.h.

Referenced by executeStudy(), and getSideNormal().

◆ _threaded_cached_traces

std::vector<std::vector<TraceData> > RayTracingStudy::_threaded_cached_traces
private

The threaded storage for cached traces.

Definition at line 1042 of file RayTracingStudy.h.

Referenced by executeStudy(), and initThreadedCachedTrace().

◆ _threaded_current_ray_kernels

std::vector<std::vector<RayKernelBase *> > RayTracingStudy::_threaded_current_ray_kernels
private

The current RayKernel objects for each thread.

Definition at line 1075 of file RayTracingStudy.h.

Referenced by currentRayKernels(), currentRayKernelsWrite(), executeStudy(), and segmentSubdomainSetup().

◆ _threaded_elem_side_builders

std::vector<libMesh::ElemSideBuilder> RayTracingStudy::_threaded_elem_side_builders
private

Threaded helpers for building element sides without extraneous allocation.

Definition at line 1014 of file RayTracingStudy.h.

Referenced by elemSide().

◆ _threaded_fe_face

std::vector<std::unique_ptr<libMesh::FEBase> > RayTracingStudy::_threaded_fe_face
private

Face FE used for computing face normals for each thread.

Definition at line 1079 of file RayTracingStudy.h.

Referenced by getSideNormal(), and RayTracingStudy().

◆ _threaded_next_ray_id

std::vector<RayID> RayTracingStudy::_threaded_next_ray_id
private

Storage for the next available unique RayID, obtained via generateUniqueRayID()

Definition at line 1088 of file RayTracingStudy.h.

Referenced by generateUniqueRayID(), and resetUniqueRayIDs().

◆ _threaded_q_face

std::vector<std::unique_ptr<libMesh::QBase> > RayTracingStudy::_threaded_q_face
private

Face quadrature used for computing face normals for each thread.

Definition at line 1081 of file RayTracingStudy.h.

Referenced by RayTracingStudy().

◆ _threaded_ray_object_registration

std::vector<std::vector<std::set<const RayTracingObject *> > > RayTracingStudy::_threaded_ray_object_registration
private

Threaded storage for all of the RayTracingObjects associated with a single Ray.

Definition at line 1073 of file RayTracingStudy.h.

Referenced by getRayBCs(), getRayKernels(), and registeredRaySetup().

◆ _threaded_trace_ray

std::vector<std::shared_ptr<TraceRay> > RayTracingStudy::_threaded_trace_ray
private

The TraceRay objects for each thread (they do the physical tracing)

Definition at line 1077 of file RayTracingStudy.h.

Referenced by executeStudy(), meshChanged(), RayTracingStudy(), and traceRay().

◆ _tolerate_failure

const bool RayTracingStudy::_tolerate_failure
protected

Whether or not to tolerate a Ray Tracing failure.

Definition at line 876 of file RayTracingStudy.h.

Referenced by executeStudy(), and tolerateFailure().

◆ _total_distance

Real RayTracingStudy::_total_distance
private

Total distance traveled by all Rays.

Definition at line 1123 of file RayTracingStudy.h.

Referenced by executeStudy(), and totalDistance().

◆ _total_intersections

unsigned long long int RayTracingStudy::_total_intersections
private

Total number of Ray/element intersections.

Definition at line 1114 of file RayTracingStudy.h.

Referenced by executeStudy(), and totalIntersections().

◆ _total_processor_crossings

unsigned long long int RayTracingStudy::_total_processor_crossings
private

Total number of processor crossings.

Definition at line 1103 of file RayTracingStudy.h.

Referenced by executeStudy(), and totalProcessorCrossings().

◆ _total_volume

Real RayTracingStudy::_total_volume
private

The total volume of the domain.

Definition at line 1066 of file RayTracingStudy.h.

Referenced by totalVolume().

◆ _use_internal_sidesets

const bool RayTracingStudy::_use_internal_sidesets
protected

Whether or not to use the internal sidesets in ray tracing.

Definition at line 874 of file RayTracingStudy.h.

Referenced by internalSidesetSetup().

◆ _use_ray_registration

const bool RayTracingStudy::_use_ray_registration
protected

Whether or not to use Ray registration.

Definition at line 872 of file RayTracingStudy.h.

Referenced by getRayBCs(), getRayKernels(), registeredRayID(), registeredRayName(), registeredRaySetup(), registerRay(), and useRayRegistration().

◆ _verify_rays

const bool RayTracingStudy::_verify_rays
protected

Whether or not to verify if Rays have valid information before being traced.

Definition at line 893 of file RayTracingStudy.h.

Referenced by verifyRays().

◆ _verify_trace_intersections

const bool RayTracingStudy::_verify_trace_intersections
protected

Whether or not to verify the trace intersections in devel and dbg modes.

Definition at line 896 of file RayTracingStudy.h.

Referenced by verifyTraceIntersections().

◆ _warn_non_planar

const bool RayTracingStudy::_warn_non_planar
protected

Whether not to warn if non-planar faces are found.

Definition at line 870 of file RayTracingStudy.h.

Referenced by nonPlanarSideSetup(), and warnNonPlanar().


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