https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
RayTracingMeshOutput Class Referenceabstract

Base class for outputting Ray data in a mesh format, where EDGE2 elems represent the individual Ray segments. More...

#include <RayTracingMeshOutput.h>

Inheritance diagram for RayTracingMeshOutput:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 RayTracingMeshOutput (const InputParameters &parameters)
 
virtual std::string filename () override
 
void output () override
 
void setFileBase (const std::string &file_base)
 
void setFileNumber (unsigned int num)
 
unsigned int getFileNumber ()
 
virtual Real time () override
 
virtual Real timeOld ()
 
virtual Real dt ()
 
virtual Real dtOld ()
 
virtual int timeStep ()
 
const unsigned intinterval () const
 
const MultiMooseEnumexecuteOn () const
 
bool isAdvanced ()
 
virtual const OutputOnWarehouseadvancedExecuteOn () const
 
void allowOutput (bool state)
 
virtual void outputStep (const ExecFlagType &type)
 
const std::set< Real > & getSyncTimes ()
 
virtual bool supportsMaterialPropertyOutput () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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 meshChanged ()
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
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
 
Moose::Kokkos::Function getKokkosFunction (const std::string &name) const
 
const TgetKokkosFunction (const std::string &name) const
 
Moose::Kokkos::Function getKokkosFunctionByName (const FunctionName &name) const
 
const TgetKokkosFunctionByName (const FunctionName &name) const
 
bool hasKokkosFunction (const std::string &param_name) const
 
bool hasKokkosFunctionByName (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
 
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 Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const TgetUserObject (const std::string &param_name, bool is_dependency=true) const
 
const TgetUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) 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 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
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static ExecFlagEnum getDefaultExecFlagEnum ()
 
static void addDeprecatedInputParameters (InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

virtual void outputMesh ()=0
 Output the mesh - to be overridden.
 
virtual std::string fileExtension () const =0
 Return the file extension.
 
virtual bool shouldOutput () override
 
bool checkFilename ()
 
virtual void setFileBaseInternal (const std::string &file_base)
 
bool inNonlinearTimeWindow ()
 
bool inLinearTimeWindow ()
 
virtual Real getOutputTime ()
 
virtual bool onInterval ()
 
void setWallTimeIntervalFromCommandLineParam ()
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const
 
const ReporterContextBasegetReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
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
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (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
 
virtual void addUserObjectDependencyHelper (const UserObjectBase &) const
 

Static Protected Member Functions

static PetscErrorCode petscNonlinearOutput (SNES, PetscInt its, PetscReal fnorm, void *void_ptr)
 
static PetscErrorCode petscLinearOutput (KSP, PetscInt its, PetscReal fnorm, void *void_ptr)
 

Protected Attributes

const RayTracingStudy_study
 The RayTracingStudy.
 
const bool _output_data
 Whether or not to output all of the Ray's data.
 
const std::vector< std::string > *const _output_data_names
 Specific Ray data to output.
 
const bool _output_data_nodal
 Whether or not to output the Ray's data in a nodal, linear sense.
 
const bool _output_aux_data
 Whether or not to output the Ray's aux data.
 
const std::vector< std::string > *const _output_aux_data_names
 Specific Ray Aux data to output.
 
std::unique_ptr< MeshBase > _segment_mesh
 The mesh that contains the segments.
 
std::unique_ptr< libMesh::EquationSystems_es
 The EquationSystems.
 
libMesh::ExplicitSystem_sys
 The system that stores the field data.
 
unsigned int_file_num
 
unsigned int _padding
 
std::vector< std::string > _output_if_base_contains
 
std::string _file_base
 
Real _norm
 
PetscInt _nonlinear_iter
 
PetscInt _linear_iter
 
bool _on_linear_residual
 
bool _on_nonlinear_residual
 
FEProblemBase_problem_ptr
 
bool _transient
 
bool _use_displaced
 
libMesh::EquationSystems_es_ptr
 
MooseMesh_mesh_ptr
 
bool _sequence
 
ExecFlagEnum _execute_on
 
ExecFlagType _current_execute_flag
 
Real & _time
 
Real & _time_old
 
int_t_step
 
Real & _dt
 
Real & _dt_old
 
unsigned int _num
 
const bool _time_step_interval_set_by_addparam
 
unsigned int _time_step_interval
 
const Real _min_simulation_time_interval
 
Real _wall_time_interval
 
std::set< Real > _sync_times
 
const Times *const _sync_times_object
 
Real _start_time
 
Real _end_time
 
int _start_step
 
int _end_step
 
Real _t_tol
 
bool _sync_only
 
bool _allow_output
 
bool _is_advanced
 
OutputOnWarehouse _advanced_execute_on
 
Real & _last_output_simulation_time
 
std::chrono::time_point< std::chrono::steady_clock > _last_output_wall_time
 
Real _wall_time_since_last_output
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
const ExecFlagEnum_execute_enum
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
PetscOutput_petsc_output
 
const Parallel::Communicator & _communicator
 

Private Member Functions

void buildBoundingBoxes ()
 Build the inflated neighbor bounding boxes stored in _inflated_neighbor_bboxes for the purposes of identifying processors that may contain nodes that we need to decide on ownership for.
 
void buildIDMap ()
 Builds a map for each Ray to starting element and node ID for the EDGE2 mesh that will represent said Ray.
 
void buildSegmentMesh ()
 Build the mesh that contains the ray tracing segments.
 
void setupEquationSystem ()
 Setup the equation system that stores the segment-wise field data.
 
void fillFields ()
 Fill the Ray field data.
 
dof_id_type neededNodes (const TraceData &trace_data) const
 Gets the number of nodes needed to represent a given trace.
 
void startingIDs (const TraceData &trace_data, dof_id_type &start_node_id, dof_id_type &start_elem_id) const
 Gets the starting node and element IDs in the EDGE2 mesh for a given trace.
 
void solveSetup () override
 
RestartableDataValueregisterRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 
const Moose::FunctionBasegetKokkosFunctionByNameHelper (const FunctionName &name) const
 
const PostprocessorName & getPostprocessorNameInternal (const std::string &param_name, const unsigned int index, const bool allow_default_value=true) const
 
bool isDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
PostprocessorValue getDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
void checkParam (const std::string &param_name, const unsigned int index=std::numeric_limits< unsigned int >::max()) const
 
bool postprocessorsAdded () const
 
const VectorPostprocessorValuegetVectorPostprocessorByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name, bool broadcast, std::size_t t_index) const
 
const VectorPostprocessorContext< VectorPostprocessorValue > & getVectorPostprocessorContextByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool vectorPostprocessorsAdded () const
 
bool reportersAdded () const
 
void possiblyCheckHasReporter (const ReporterName &reporter_name, const std::string &param_name="") const
 
const PostprocessorValuegetPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const UserObjectBasegetUserObjectFromFEProblem (const UserObjectName &object_name, const THREAD_ID tid=0) const
 
const TcastUserObject (const UserObjectBase &uo_base, const std::string &param_name="") const
 
void mooseObjectError (const std::string &param_name, std::stringstream &oss) const
 
const std::string & userObjectType (const UserObjectBase &uo) const
 
const std::string & userObjectName (const UserObjectBase &uo) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

unsigned int _ray_id_var
 The variable index in _sys for the Ray's ID (if any)
 
unsigned int _intersections_var
 The variable index in _sys for the intersection ID (if any)
 
unsigned int _pid_var
 The variable index in _sys for the Ray's processor id (if any)
 
unsigned int _processor_crossings_var
 The variable index in _sys for the Ray's processor crossings (if any)
 
unsigned int _trajectory_changes_var
 The variable index in _sys for the Ray's trajectory changes (if any)
 
std::vector< std::pair< RayDataIndex, unsigned int > > _data_vars
 The ray data index -> variable index map.
 
std::vector< std::pair< RayDataIndex, unsigned int > > _aux_data_vars
 The ray aux data index -> variable index map.
 
BoundingBox _bbox
 The bounding box for this processor.
 
std::vector< BoundingBox > _inflated_bboxes
 The inflated bounding boxes for all processors.
 
std::vector< std::pair< processor_id_type, BoundingBox > > _inflated_neighbor_bboxes
 Inflated bounding boxes that are neighboring to this processor (pid : bbox for each entry)
 
std::unordered_map< RayID, std::pair< dof_id_type, dof_id_type > > _ray_starting_id_map
 The map from RayID to the starting element and node ID of the mesh element for said Ray.
 
dof_id_type _max_node_id
 The max node ID for the ray tracing mesh for creating unique elem IDs.
 
bool _segmented_rays
 Whether or not we have segmented rays.
 
Real _nonlinear_time
 
Real _nonlinear_dt
 
Real _linear_time
 
Real _linear_dt
 
Real _nonlinear_dt_divisor
 
Real _linear_dt_divisor
 
Real _nonlinear_start_time
 
Real _linear_start_time
 
Real _nonlinear_end_time
 
Real _linear_end_time
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 
ExecFlagEnum _empty_execute_enum
 
const MooseObject_fni_object
 
const InputParameters_fni_params
 
FEProblemBase_fni_feproblem
 
const THREAD_ID _fni_tid
 
const MooseObject_ppi_moose_object
 
const InputParameters_ppi_params
 
const FEProblemBase_ppi_feproblem
 
std::map< PostprocessorName, std::unique_ptr< PostprocessorValue > > _default_values
 
const bool _broadcast_by_default
 
const MooseObject_vpi_moose_object
 
const FEProblemBase_vpi_feproblem
 
const THREAD_ID _vpi_tid
 
const InputParameters_ri_params
 
FEProblemBase_ri_fe_problem_base
 
const ReporterData_ri_reporter_data
 
const MooseObject_ri_moose_object
 
const MooseObject_uoi_moose_object
 
const FEProblemBase_uoi_feproblem
 
const THREAD_ID _uoi_tid
 

Detailed Description

Base class for outputting Ray data in a mesh format, where EDGE2 elems represent the individual Ray segments.

Definition at line 33 of file RayTracingMeshOutput.h.

Constructor & Destructor Documentation

◆ RayTracingMeshOutput()

RayTracingMeshOutput::RayTracingMeshOutput ( const InputParameters parameters)

Definition at line 54 of file RayTracingMeshOutput.C.

55 : FileOutput(params),
57 _study(getUserObject<RayTracingStudy>("study")),
58 _output_data(getParam<bool>("output_data")),
59 _output_data_names(isParamValid("output_data_names")
60 ? &getParam<std::vector<std::string>>("output_data_names")
61 : nullptr),
62 _output_data_nodal(getParam<bool>("output_data_nodal")),
63 _output_aux_data(getParam<bool>("output_aux_data")),
64 _output_aux_data_names(isParamValid("output_aux_data_names")
65 ? &getParam<std::vector<std::string>>("output_aux_data_names")
66 : nullptr),
72 _segmented_rays(false)
73{
75 mooseError("In order to output Ray data in output '",
76 name(),
77 "', the RayTracingStudy '",
78 _study.name(),
79 "' must set data_on_cache_traces = true");
81 mooseError("In order to output Ray aux data in output '",
82 name(),
83 "', the RayTracingStudy '",
84 _study.name(),
85 "' must set aux_data_on_cache_traces = true");
87 paramError("output_data_nodal",
88 "Cannot be used unless there is data to output; in addition set either "
89 "'output_data' or 'output_data_names");
91 paramError("output_data_nodal", "Not supported when study segments_on_cache_traces = false");
93 paramError("output_data", "Cannot be used in addition to 'output_data_names'; choose one");
95 paramError("output_aux_data",
96 "Cannot be used in addition to 'output_aux_data_names'; choose one");
97}
const std::string & name() const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
unsigned int _intersections_var
The variable index in _sys for the intersection ID (if any)
unsigned int _ray_id_var
The variable index in _sys for the Ray's ID (if any)
const std::vector< std::string > *const _output_aux_data_names
Specific Ray Aux data to output.
const bool _output_aux_data
Whether or not to output the Ray's aux data.
bool _segmented_rays
Whether or not we have segmented rays.
unsigned int _pid_var
The variable index in _sys for the Ray's processor id (if any)
const bool _output_data
Whether or not to output all of the Ray's data.
const bool _output_data_nodal
Whether or not to output the Ray's data in a nodal, linear sense.
unsigned int _processor_crossings_var
The variable index in _sys for the Ray's processor crossings (if any)
const RayTracingStudy & _study
The RayTracingStudy.
const std::vector< std::string > *const _output_data_names
Specific Ray data to output.
unsigned int _trajectory_changes_var
The variable index in _sys for the Ray's trajectory changes (if any)
bool segmentsOnCacheTraces() const
Whether or not to cache individual element segments when _cache_traces = true.
bool auxDataOnCacheTraces() const
Whether or not to store the Ray aux data on the cached Ray traces.
bool dataOnCacheTraces() const
Whether or not to store the Ray data on the cached Ray traces.
const unsigned int invalid_uint

Member Function Documentation

◆ buildBoundingBoxes()

void RayTracingMeshOutput::buildBoundingBoxes ( )
private

Build the inflated neighbor bounding boxes stored in _inflated_neighbor_bboxes for the purposes of identifying processors that may contain nodes that we need to decide on ownership for.

Definition at line 651 of file RayTracingMeshOutput.C.

652{
653 TIME_SECTION("buildBoundingBoxes", 3, "Building Bounding Boxes for RayTracing Mesh Output");
654
655 // Not used in the one proc case
656 if (_communicator.size() == 1)
657 return;
658
659 // Local bounding box
660 _bbox = MeshTools::create_local_bounding_box(_mesh_ptr->getMesh());
661
662 // Gather the bounding boxes of all processors
663 std::vector<std::pair<Point, Point>> bb_points = {static_cast<std::pair<Point, Point>>(_bbox)};
664 _communicator.allgather(bb_points, true);
666 for (processor_id_type pid = 0; pid < _communicator.size(); ++pid)
667 {
668 BoundingBox pid_bbox = static_cast<BoundingBox>(bb_points[pid]);
669 pid_bbox.scale(0.01);
670 _inflated_bboxes[pid] = pid_bbox;
671 }
672
673 // Find intersecting (neighbor) bounding boxes
675 for (processor_id_type pid = 0; pid < _communicator.size(); ++pid)
676 if (pid != processor_id())
677 {
678 // Insert if the searched processor's bbox intersects my bbox
679 const auto & pid_bbox = _inflated_bboxes[pid];
680 if (_bbox.intersects(pid_bbox))
681 _inflated_neighbor_bboxes.emplace_back(pid, pid_bbox);
682 }
683}
MeshBase & getMesh()
MooseMesh * _mesh_ptr
std::vector< BoundingBox > _inflated_bboxes
The inflated bounding boxes for all processors.
std::vector< std::pair< processor_id_type, BoundingBox > > _inflated_neighbor_bboxes
Inflated bounding boxes that are neighboring to this processor (pid : bbox for each entry)
BoundingBox _bbox
The bounding box for this processor.
processor_id_type size() const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
const Parallel::Communicator & _communicator
processor_id_type processor_id() const

Referenced by output().

◆ buildIDMap()

void RayTracingMeshOutput::buildIDMap ( )
private

Builds a map for each Ray to starting element and node ID for the EDGE2 mesh that will represent said Ray.

Definition at line 148 of file RayTracingMeshOutput.C.

149{
150 TIME_SECTION("buildIDMap", 3, "Building RayTracing ID Map");
151
152 // Build the maximum number of nodes required to represent each one of my local Rays
153 std::map<RayID, dof_id_type> local_ray_needed_nodes;
154 for (const auto & trace_data : _study.getCachedTraces())
155 {
156 const auto find = local_ray_needed_nodes.find(trace_data._ray_id);
157 if (find == local_ray_needed_nodes.end())
158 local_ray_needed_nodes[trace_data._ray_id] = neededNodes(trace_data);
159 else
160 {
161 auto & value = find->second;
162 value = std::max(value, neededNodes(trace_data));
163 }
164 }
165
166 // Fill all of my local Ray maxima to be sent to processor 0
167 std::map<processor_id_type, std::vector<std::pair<RayID, dof_id_type>>> send_needed_nodes;
168 if (local_ray_needed_nodes.size())
169 {
170 auto & root_entry = send_needed_nodes[0];
171 for (const auto & id_nodes_pair : local_ray_needed_nodes)
172 root_entry.emplace_back(id_nodes_pair);
173 }
174
175 // The global map of ray -> required nodes needed to be filled on processor 0
176 std::map<RayID, dof_id_type> global_needed_nodes;
177 // Keep track of what Ray IDs we received from what processors so we know who to send back to
178 std::unordered_map<processor_id_type, std::set<RayID>> pid_received_ids;
179 // Take the required nodes for each Ray and determine on processor 0 the global maximum
180 // nodes needed to represent each Ray
181 const auto append_global_max =
182 [&global_needed_nodes, &pid_received_ids](
183 processor_id_type pid, const std::vector<std::pair<RayID, dof_id_type>> & pairs)
184 {
185 auto & pid_received_entry = pid_received_ids[pid];
186 for (const auto & id_max_pair : pairs)
187 {
188 const RayID ray_id = id_max_pair.first;
189 const dof_id_type max = id_max_pair.second;
190
191 const auto find = global_needed_nodes.find(ray_id);
192 if (find == global_needed_nodes.end())
193 global_needed_nodes.emplace(ray_id, max);
194 else
195 {
196 auto & current_max = find->second;
197 current_max = std::max(current_max, max);
198 }
199
200 pid_received_entry.insert(ray_id);
201 }
202 };
203 Parallel::push_parallel_vector_data(comm(), send_needed_nodes, append_global_max);
204
205 // Decide on the starting representative starting node and elem ID for each Ray
206 std::map<RayID, std::pair<dof_id_type, dof_id_type>> global_ids;
207 dof_id_type current_node_id = 0;
208 dof_id_type current_elem_id = 0;
209 for (auto & pair : global_needed_nodes)
210 {
211 const RayID ray_id = pair.first;
212 const dof_id_type max_nodes = pair.second;
213
214 global_ids.emplace(ray_id, std::make_pair(current_node_id, current_elem_id));
215
216 current_node_id += max_nodes;
217 if (max_nodes > 1)
218 current_elem_id += max_nodes - 1;
219 else // stationary
220 current_elem_id += 1;
221 }
222
223 // Share the max node IDs so that we have a starting point for unique IDs for elems
224 _max_node_id = current_node_id;
226
227 // Fill the starting ID information to each processor that needs it from processor 0
228 std::unordered_map<processor_id_type, std::vector<std::tuple<RayID, dof_id_type, dof_id_type>>>
229 send_ids;
230 for (auto & pid_ids_pair : pid_received_ids)
231 {
232 const processor_id_type pid = pid_ids_pair.first;
233 const std::set<RayID> & ray_ids = pid_ids_pair.second;
234
235 auto & pid_send = send_ids[pid];
236 for (const RayID ray_id : ray_ids)
237 {
238 const auto & global_entry = global_ids.at(ray_id);
239 const dof_id_type node_id = global_entry.first;
240 const dof_id_type elem_id = global_entry.second;
241 pid_send.emplace_back(ray_id, node_id, elem_id);
242 }
243 }
244
245 // Take the starting ID information from processor 0 and store it locally
246 const auto append_ids =
248 const std::vector<std::tuple<RayID, dof_id_type, dof_id_type>> & tuples)
249 {
250 for (const auto & tuple : tuples)
251 {
252 const RayID ray_id = std::get<0>(tuple);
253 const dof_id_type node_id = std::get<1>(tuple);
254 const dof_id_type elem_id = std::get<2>(tuple);
255 _ray_starting_id_map.emplace(ray_id, std::make_pair(node_id, elem_id));
256 }
257 };
258
259 _ray_starting_id_map.clear();
260 Parallel::push_parallel_vector_data(comm(), send_ids, append_ids);
261}
unsigned long int RayID
Type for a Ray's ID.
Definition Ray.h:44
dof_id_type neededNodes(const TraceData &trace_data) const
Gets the number of nodes needed to represent a given trace.
std::unordered_map< RayID, std::pair< dof_id_type, dof_id_type > > _ray_starting_id_map
The map from RayID to the starting element and node ID of the mesh element for said Ray.
dof_id_type _max_node_id
The max node ID for the ray tracing mesh for creating unique elem IDs.
void max(const T &r, T &o, Request &req) const
const Parallel::Communicator & comm() const
auto max(const L &left, const R &right)
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
uint8_t processor_id_type
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
uint8_t dof_id_type

Referenced by buildSegmentMesh().

◆ buildSegmentMesh()

void RayTracingMeshOutput::buildSegmentMesh ( )
private

Build the mesh that contains the ray tracing segments.

Definition at line 264 of file RayTracingMeshOutput.C.

265{
266 TIME_SECTION("buildSegmentMesh", 3, "Building RayTracing Mesh Output");
267
268 _segmented_rays = false;
269
270 // Tally nodes and elems for the local mesh ahead of time so we can reserve
271 // Each segment requires an element, and we need one more node than elems
272 dof_id_type num_nodes = 0;
273 dof_id_type num_elems = 0;
274 for (const auto & entry : _study.getCachedTraces())
275 {
276 const auto num_segments = entry.numSegments();
277 num_nodes += num_segments + 1;
278 if (num_segments >= 1)
279 {
280 _segmented_rays = true;
281 num_elems += num_segments;
282 }
283 else if (entry.stationary())
284 num_elems += 1;
285 }
286
288
289 // Build the segment mesh
290 mooseAssert(!_segment_mesh, "Not cleared");
291 if (_communicator.size() == 1)
292 _segment_mesh = std::make_unique<ReplicatedMesh>(_communicator, _mesh_ptr->dimension());
293 else
294 {
295 _segment_mesh = std::make_unique<DistributedMesh>(_communicator, _mesh_ptr->dimension());
296 _segment_mesh->set_distributed();
297 }
298 // We set neighbor links
299 _segment_mesh->allow_find_neighbors(false);
300 // Don't renumber so that we can remain consistent between processor counts
301 _segment_mesh->allow_renumbering(false);
302 // As we're building segments for just this partiton, we're partitioning on our own
303 _segment_mesh->skip_partitioning(true);
304 // Reserve nodes and elems
305 _segment_mesh->reserve_nodes(num_nodes);
306 _segment_mesh->reserve_elem(num_elems);
307
308 buildIDMap();
309
310 // Decide on a starting ID for each processor
311 // Build a mesh segment for each local Ray segment
312 // Each one of these objects represents a single Ray's path through this processor
313 for (const auto & trace_data : _study.getCachedTraces())
314 {
315 // If we have no segments, this is a trace that skimmed the corner of a processor boundary and
316 // didn't contribute anything
317 if (trace_data.numSegments() == 0 && !trace_data.stationary())
318 continue;
319
320 dof_id_type node_id, elem_id;
321 startingIDs(trace_data, node_id, elem_id);
322
323 // Add the start point
324 mooseAssert(!_segment_mesh->query_node_ptr(node_id), "Node already exists");
325 Node * last_node =
326 _segment_mesh->add_point(trace_data._point_data[0]._point, node_id, processor_id());
327 last_node->set_unique_id(node_id++);
328
329 // Stationary, add a NodeElem
330 if (trace_data.stationary())
331 {
332 mooseAssert(!_segment_mesh->query_elem_ptr(elem_id), "Elem already exists");
333 auto elem = _segment_mesh->add_elem(Elem::build_with_id(NODEELEM, elem_id));
334 elem->processor_id(processor_id());
335 elem->set_unique_id(_max_node_id + elem_id++);
336 elem->set_node(0, last_node);
337 }
338 // Not stationary; add a point and element for each segment
339 else
340 {
341 Elem * last_elem = nullptr;
342
343 for (std::size_t i = 1; i < trace_data._point_data.size(); ++i)
344 {
345 const auto & point = trace_data._point_data[i]._point;
346
347 // Add next point on the trace
348 mooseAssert(!_segment_mesh->query_node_ptr(node_id), "Node already exists");
349 Node * node = _segment_mesh->add_point(point, node_id, processor_id());
350 node->set_unique_id(node_id++);
351
352 // Build a segment from this point to the last
353 mooseAssert(!_segment_mesh->query_elem_ptr(elem_id), "Elem already exists");
354 Elem * elem = _segment_mesh->add_elem(Elem::build_with_id(EDGE2, elem_id));
355 elem->processor_id(processor_id());
356 elem->set_unique_id(_max_node_id + elem_id++);
357 elem->set_node(0, last_node);
358 elem->set_node(1, node);
359
360 // Set neighbor links
361 if (last_elem)
362 {
363 elem->set_neighbor(0, last_elem);
364 last_elem->set_neighbor(1, elem);
365 }
366
367 last_elem = elem;
368 last_node = node;
369 }
370 }
371 }
372
373 // If the mesh is replicated, everything that follows is unnecessary. Prepare and be done.
374 if (_segment_mesh->is_replicated())
375 {
376 _segment_mesh->prepare_for_use();
377 return;
378 }
379
380 // Find the Nodes on processor boundaries that we need to decide on owners for. Also set up
381 // remote_elem links for neighbors we clearly don't have. We don't build the neighbor maps at
382 // all, so all we have are nullptr and remote_elem. We can only do all of this after the mesh is
383 // built because the mesh isn't necessarily built in the order Rays are traced
384 std::vector<Node *> need_node_owners;
385 for (const auto & trace_data : _study.getCachedTraces())
386 {
387 const auto num_segments = trace_data.numSegments();
388
389 if (num_segments == 0)
390 continue;
391
392 dof_id_type start_node_id, start_elem_id;
393 startingIDs(trace_data, start_node_id, start_elem_id);
394
395 // Another part of the trace for this Ray happened before this one
396 if ((_study.segmentsOnCacheTraces() ? trace_data._intersections
397 : (unsigned long int)(trace_data._processor_crossings +
398 trace_data._trajectory_changes)) != 0)
399 {
400 // The element before start_elem (may be nullptr, meaning it didn't trace on this proc)
401 Elem * previous_elem = _segment_mesh->query_elem_ptr(start_elem_id - 1);
402
403 // We don't have the previous element segment, so it exists on another processor
404 // Set the remote_elem and mark that we need to find out who owns the first node on this
405 // trace
406 if (!previous_elem)
407 {
408 Elem * start_elem = _segment_mesh->elem_ptr(start_elem_id);
409 start_elem->set_neighbor(0, const_cast<RemoteElem *>(remote_elem));
410 start_elem->node_ptr(0)->invalidate_processor_id();
411 need_node_owners.push_back(start_elem->node_ptr(0));
412 }
413 }
414
415 // If you have multiple sets of segments on a single processor, it is possible
416 // to have part of the trace on another processor within the segments we know about.
417 // In this case, we have to do some magic to the neighbor links so that the mesh
418 // doesn't fail in assertions.
419 if (!trace_data._last)
420 {
421 // The element after end_elem (may be nullptr, meaning it didn't happen on this proc)
422 Elem * next_elem = _segment_mesh->query_elem_ptr(start_elem_id + num_segments);
423
424 // We have the next element from another trace, set neighbors as we own both
425 if (!next_elem)
426 {
427 Elem * end_elem = _segment_mesh->elem_ptr(start_elem_id + num_segments - 1);
428 end_elem->set_neighbor(1, const_cast<RemoteElem *>(remote_elem));
429 end_elem->node_ptr(1)->invalidate_processor_id();
430 need_node_owners.push_back(end_elem->node_ptr(1));
431 }
432 }
433 }
434
435 // Sort through the neighboring bounding boxes and prepare requests to each processor that /may/
436 // also have one of the nodes that we need to decide on an owner for
437 std::unordered_map<processor_id_type, std::vector<dof_id_type>> need_node_owners_sends;
438 for (const Node * node : need_node_owners)
439 for (const auto & neighbor_pid_bbox_pair : _inflated_neighbor_bboxes)
440 {
441 const auto neighbor_pid = neighbor_pid_bbox_pair.first;
442 const auto & neighbor_bbox = neighbor_pid_bbox_pair.second;
443 if (neighbor_bbox.contains_point(*node))
444 need_node_owners_sends[neighbor_pid].push_back(node->id());
445 }
446
447 // Functor that takes in a set of incoming node IDs from a processor and decides on an owner.
448 // For every node that we need an owner for, this should be called for said node on both
449 // processors. Therefore, just pick the minimum processor ID as the owner. This should never
450 // happen more than once for a single node because we're building 1D elems and we can only ever
451 // have two procs that touch a node.
452 std::unordered_map<processor_id_type, std::vector<dof_id_type>> confirm_node_owners_sends;
453 auto decide_node_owners_functor =
454 [this, &confirm_node_owners_sends](processor_id_type pid,
455 const std::vector<dof_id_type> & incoming_node_ids)
456 {
457 auto & confirm_pid = confirm_node_owners_sends[pid];
458 for (const auto & node_id : incoming_node_ids)
459 {
460 Node * node = _segment_mesh->query_node_ptr(node_id);
461 if (node)
462 {
463 mooseAssert(!node->valid_processor_id(), "Should be invalid");
464 node->processor_id() = std::min(pid, processor_id());
465 confirm_pid.push_back(node_id);
466 }
467 }
468 };
469
470 // Ship the nodes that need owners for and pick an owner when we receive
471 Parallel::push_parallel_vector_data(
472 _communicator, need_node_owners_sends, decide_node_owners_functor);
473
474 // At this point, any nodes that we actually need ghosts for should have their processor_ids
475 // satisfied. Anything that is left isn't actually ghosted and is ours. Therefore, set
476 // everything left that is invalid to be owned by this proc.
477 for (Node * node : need_node_owners)
478 if (!node->valid_processor_id())
479 node->processor_id() = processor_id();
480
481 // We're done!
482 _segment_mesh->prepare_for_use();
483}
for(PetscInt i=0;i< nvars;++i)
void ErrorVector unsigned int
virtual unsigned int dimension() const
std::unique_ptr< MeshBase > _segment_mesh
The mesh that contains the segments.
void startingIDs(const TraceData &trace_data, dof_id_type &start_node_id, dof_id_type &start_elem_id) const
Gets the starting node and element IDs in the EDGE2 mesh for a given trace.
void buildIDMap()
Builds a map for each Ray to starting element and node ID for the EDGE2 mesh that will represent said...
if(subdm)

Referenced by output().

◆ fileExtension()

virtual std::string RayTracingMeshOutput::fileExtension ( ) const
protectedpure virtual

Return the file extension.

Implemented in RayTracingExodus, and RayTracingNemesis.

Referenced by filename().

◆ filename()

std::string RayTracingMeshOutput::filename ( )
overridevirtual

Reimplemented from FileOutput.

Definition at line 100 of file RayTracingMeshOutput.C.

101{
102 // Append the file extension on the base file name
103 std::ostringstream output;
105
106 // Add the _000x extension to the file
107 if (_file_num > 0)
108 output << "-s" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right
109 << _file_num;
110
111 // Return the filename
112 return output.str();
113}
unsigned int _padding
std::string _file_base
unsigned int & _file_num
virtual std::string fileExtension() const =0
Return the file extension.

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

◆ fillFields()

void RayTracingMeshOutput::fillFields ( )
private

Fill the Ray field data.

Definition at line 572 of file RayTracingMeshOutput.C.

573{
574 TIME_SECTION("fillFields", 3, "Filling RayTracing MeshOutput Fields");
575
576 // Helper for setting the solution (if enabled)
577 const auto set_solution =
578 [this](const DofObject * const dof, const unsigned int var, const Real value)
579 {
580 mooseAssert(dof, "Nullptr dof");
581 if (var != invalid_uint)
582 {
583 const auto dof_number = dof->dof_number(_sys->number(), var, 0);
584 _sys->solution->set(dof_number, value);
585 }
586 };
587
588 // Helper for filling data and aux data (if enabled)
589 const auto fill_data =
590 [&set_solution](const DofObject * const dof, const auto & vars, const auto & data)
591 {
592 mooseAssert(dof, "Nullptr dof");
593 for (const auto & [data_index, var_num] : vars)
594 set_solution(dof, var_num, data[data_index]);
595 };
596
597 for (const auto & trace_data : _study.getCachedTraces())
598 {
599 auto intersection = trace_data._intersections;
600
601 // No segments and not stationary; means this ray bounced off
602 // this processor and never actually moved on this processor
603 if (!trace_data.numSegments() && !trace_data.stationary())
604 continue;
605
606 dof_id_type node_id, elem_id;
607 startingIDs(trace_data, node_id, elem_id);
608
609 const Elem * elem = _segment_mesh->elem_ptr(elem_id);
610
611 // Fill first node's nodal data if we need it; the loop that follows will handle
612 // the rest of the nodes
613 if (_output_data_nodal && _study.hasRayData() && !trace_data.stationary())
614 fill_data(elem->node_ptr(0), _data_vars, trace_data._point_data[0]._data);
615
616 const std::size_t start = trace_data.stationary() ? 0 : 1;
617 for (const auto i : make_range(start, trace_data._point_data.size()))
618 {
619 mooseAssert(elem, "Nullptr elem");
620
621 // Elemental ID and pid
622 set_solution(elem, _ray_id_var, trace_data._ray_id);
623 set_solution(elem, _pid_var, processor_id());
624 // Elemental properties that only apply to segments
625 if (!trace_data.stationary())
626 {
627 set_solution(elem, _intersections_var, intersection++);
628 set_solution(elem, _processor_crossings_var, trace_data._processor_crossings);
629 set_solution(elem, _trajectory_changes_var, trace_data._trajectory_changes);
630 }
631 const auto & point_data = trace_data._point_data[i];
632 // Data fields
633 if (_output_data_nodal && !trace_data.stationary())
634 fill_data(elem->node_ptr(1), _data_vars, point_data._data);
635 else
636 fill_data(elem, _data_vars, point_data._data);
637 // Aux data fields
638 fill_data(elem, _aux_data_vars, point_data._aux_data);
639
640 // Advance to the next element
641 if (!trace_data.stationary())
642 elem = elem->neighbor_ptr(1);
643 }
644 }
645
646 _sys->solution->close();
647 _sys->update();
648}
char ** vars
libMesh::ExplicitSystem * _sys
The system that stores the field data.
std::vector< std::pair< RayDataIndex, unsigned int > > _data_vars
The ray data index -> variable index map.
std::vector< std::pair< RayDataIndex, unsigned int > > _aux_data_vars
The ray aux data index -> variable index map.
bool hasRayData() const
Whether or not any Ray data are registered.
std::unique_ptr< NumericVector< Number > > solution
virtual void update()
unsigned int number() const
void fill_data(std::map< processor_id_type, std::vector< std::set< unsigned int > > > &data, int M)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)

Referenced by output().

◆ neededNodes()

dof_id_type RayTracingMeshOutput::neededNodes ( const TraceData trace_data) const
private

Gets the number of nodes needed to represent a given trace.

Definition at line 704 of file RayTracingMeshOutput.C.

705{
707 return trace_data._intersections + trace_data._point_data.size();
708 return trace_data._processor_crossings + trace_data._trajectory_changes +
709 trace_data._point_data.size();
710}
std::vector< TracePointData > _point_data
The data for each point along the track.
Definition TraceData.h:78
const unsigned int _processor_crossings
Number of processor crossings thus far.
Definition TraceData.h:72
const unsigned long int _intersections
The number of intersections thus far.
Definition TraceData.h:70
const unsigned int _trajectory_changes
Number of trajectory changes thus far.
Definition TraceData.h:74

Referenced by buildIDMap().

◆ output()

void RayTracingMeshOutput::output ( )
overridevirtual

Implements FileOutput.

Definition at line 116 of file RayTracingMeshOutput.C.

117{
118 // Do we even have any traces?
119 auto num_segments = _study.getCachedTraces().size();
120 _communicator.sum(num_segments);
121 if (!num_segments)
122 mooseError("No cached trace segments were found in the study '", _study.name(), "'.");
123
124 // Build the _inflated_neighbor_bboxes
126
127 // Build the _segment_mesh
129
130 // Setup the system to store the Ray field data
132
133 // Fill the field data
134 fillFields();
135
136 // And output
137 outputMesh();
138
139 // Done with these
140 // We don't necessarily need to create a new mesh every time, but it's easier than
141 // checking if the Rays have changed from last time we built a mesh
142 _es = nullptr;
143 _sys = nullptr;
144 _segment_mesh = nullptr;
145}
void buildBoundingBoxes()
Build the inflated neighbor bounding boxes stored in _inflated_neighbor_bboxes for the purposes of id...
std::unique_ptr< libMesh::EquationSystems > _es
The EquationSystems.
void fillFields()
Fill the Ray field data.
void setupEquationSystem()
Setup the equation system that stores the segment-wise field data.
void buildSegmentMesh()
Build the mesh that contains the ray tracing segments.
virtual void outputMesh()=0
Output the mesh - to be overridden.
const std::vector< TraceData > & getCachedTraces() const
Get the cached trace data structure.

Referenced by filename().

◆ outputMesh()

virtual void RayTracingMeshOutput::outputMesh ( )
protectedpure virtual

Output the mesh - to be overridden.

Implemented in RayTracingExodus, and RayTracingNemesis.

Referenced by output().

◆ setupEquationSystem()

void RayTracingMeshOutput::setupEquationSystem ( )
private

Setup the equation system that stores the segment-wise field data.

Definition at line 486 of file RayTracingMeshOutput.C.

487{
488 TIME_SECTION("setupEquationSystem", 3, "Setting Up Ray Tracing MeshOutput Equation System");
489
490 _es = std::make_unique<EquationSystems>(*_segment_mesh);
491 _sys = &_es->add_system<libMesh::ExplicitSystem>("sys");
493 _aux_data_vars.clear();
494
495 // Add variables for the basic properties if enabled
501 for (auto & prop : _pars.get<MultiMooseEnum>("output_properties"))
502 switch (prop)
503 {
504 case 0: // ray_id (stationary and segments)
505 _ray_id_var = _sys->add_variable("ray_id", CONSTANT, MONOMIAL);
506 break;
507 case 1: // intersections (segments only)
508 if (_segmented_rays)
509 _intersections_var = _sys->add_variable("intersections", CONSTANT, MONOMIAL);
510 break;
511 case 2: // pid (stationary and segments)
512 _pid_var = _sys->add_variable("pid", CONSTANT, MONOMIAL);
513 break;
514 case 3: // processor_crossings (segments only)
515 if (_segmented_rays)
516 _processor_crossings_var = _sys->add_variable("processor_crossings", CONSTANT, MONOMIAL);
517 break;
518 case 4: // trajectory_changes (segments only)
519 if (_segmented_rays)
520 _trajectory_changes_var = _sys->add_variable("trajectory_changes", CONSTANT, MONOMIAL);
521 break;
522 default:
523 mooseError("Invalid property");
524 }
525
526 const auto get_data_vars = [this](const bool aux)
527 {
528 // The data index -> variable result
529 std::vector<std::pair<RayDataIndex, unsigned int>> vars;
530
531 const auto from_names =
533 : (_output_data ? &_study.rayDataNames() : _output_data_names);
534
535 // Nothing to output
536 if (!from_names)
537 return vars;
538
539 const auto output_data_nodal = aux ? false : _output_data_nodal;
540
541 for (const auto & name : *from_names)
542 {
543 const auto data_index =
545 if (data_index == Ray::INVALID_RAY_DATA_INDEX)
546 {
547 const std::string names_param = aux ? "output_aux_data_names" : "output_data_names";
548 const std::string data_prefix = aux ? "aux " : "";
549 paramError(names_param, "The ray ", data_prefix, "data '", name, "' is not registered");
550 }
551
552 const std::string var_prefix = aux ? "aux_" : "";
553 if (output_data_nodal)
554 _sys->add_variable(var_prefix + name, FIRST, LAGRANGE);
555 else
556 _sys->add_variable(var_prefix + name, CONSTANT, MONOMIAL);
557 const auto var_num = _sys->variable_number(var_prefix + name);
558 vars.emplace_back(data_index, var_num);
559 }
560
561 return vars;
562 };
563
564 _data_vars = get_data_vars(false);
565 _aux_data_vars = get_data_vars(true);
566
567 // All done
568 _es->init();
569}
const InputParameters & _pars
const std::vector< std::string > & rayAuxDataNames() const
The Ray aux data names.
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
RayDataIndex getRayAuxDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray aux data.
static const RayDataIndex INVALID_RAY_DATA_INDEX
Invalid index into a Ray's data.
Definition Ray.h:212
virtual void clear() override
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
unsigned int variable_number(std::string_view var) const
const Elem & get(const ElemType type_in)

Referenced by output().

◆ startingIDs()

void RayTracingMeshOutput::startingIDs ( const TraceData trace_data,
dof_id_type &  start_node_id,
dof_id_type &  start_elem_id 
) const
private

Gets the starting node and element IDs in the EDGE2 mesh for a given trace.

Definition at line 686 of file RayTracingMeshOutput.C.

689{
690 const auto [begin_node_id, begin_elem_id] = _ray_starting_id_map.at(trace_data._ray_id);
691
692 const auto offset =
693 trace_data.stationary()
694 ? 1
696 ? trace_data._intersections
697 : (trace_data._processor_crossings + trace_data._trajectory_changes));
698
699 start_node_id = begin_node_id + offset;
700 start_elem_id = begin_elem_id + offset;
701}
bool stationary() const
Definition TraceData.h:59
const RayID _ray_id
The Ray ID.
Definition TraceData.h:68

Referenced by buildSegmentMesh(), and fillFields().

◆ validParams()

InputParameters RayTracingMeshOutput::validParams ( )
static

Definition at line 28 of file RayTracingMeshOutput.C.

29{
31
32 params.addRequiredParam<UserObjectName>("study", "The RayTracingStudy to get the segments from");
33
34 params.addParam<bool>("output_data", false, "Whether or not to also output the Ray's data");
35 params.addParam<std::vector<std::string>>("output_data_names",
36 "The names of specific data to output");
37 params.addParam<bool>("output_data_nodal",
38 false,
39 "Whether or not to output the Ray's data in a nodal sense, in which the "
40 "data is interpolated linearly across segments");
41
42 params.addParam<bool>(
43 "output_aux_data", false, "Whether or not to also output the Ray's aux data");
44 params.addParam<std::vector<std::string>>("output_aux_data_names",
45 "The names of specific aux data to output");
46
47 MultiMooseEnum props("ray_id intersections pid processor_crossings trajectory_changes",
48 "ray_id intersections");
49 params.addParam<MultiMooseEnum>("output_properties", props, "Which Ray properties to output");
50
51 return params;
52}
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)

Referenced by RayTracingExodus::validParams(), and RayTracingNemesis::validParams().

Member Data Documentation

◆ _aux_data_vars

std::vector<std::pair<RayDataIndex, unsigned int> > RayTracingMeshOutput::_aux_data_vars
private

The ray aux data index -> variable index map.

Definition at line 122 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _bbox

BoundingBox RayTracingMeshOutput::_bbox
private

The bounding box for this processor.

Definition at line 125 of file RayTracingMeshOutput.h.

Referenced by buildBoundingBoxes().

◆ _data_vars

std::vector<std::pair<RayDataIndex, unsigned int> > RayTracingMeshOutput::_data_vars
private

The ray data index -> variable index map.

Definition at line 120 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _es

std::unique_ptr<libMesh::EquationSystems> RayTracingMeshOutput::_es
protected

The EquationSystems.

Definition at line 70 of file RayTracingMeshOutput.h.

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

◆ _inflated_bboxes

std::vector<BoundingBox> RayTracingMeshOutput::_inflated_bboxes
private

The inflated bounding boxes for all processors.

Definition at line 127 of file RayTracingMeshOutput.h.

Referenced by buildBoundingBoxes().

◆ _inflated_neighbor_bboxes

std::vector<std::pair<processor_id_type, BoundingBox> > RayTracingMeshOutput::_inflated_neighbor_bboxes
private

Inflated bounding boxes that are neighboring to this processor (pid : bbox for each entry)

Definition at line 129 of file RayTracingMeshOutput.h.

Referenced by buildBoundingBoxes(), and buildSegmentMesh().

◆ _intersections_var

unsigned int RayTracingMeshOutput::_intersections_var
private

The variable index in _sys for the intersection ID (if any)

Definition at line 112 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _max_node_id

dof_id_type RayTracingMeshOutput::_max_node_id
private

The max node ID for the ray tracing mesh for creating unique elem IDs.

Definition at line 134 of file RayTracingMeshOutput.h.

Referenced by buildIDMap(), and buildSegmentMesh().

◆ _output_aux_data

const bool RayTracingMeshOutput::_output_aux_data
protected

Whether or not to output the Ray's aux data.

Definition at line 63 of file RayTracingMeshOutput.h.

Referenced by RayTracingMeshOutput(), and setupEquationSystem().

◆ _output_aux_data_names

const std::vector<std::string>* const RayTracingMeshOutput::_output_aux_data_names
protected

Specific Ray Aux data to output.

Definition at line 65 of file RayTracingMeshOutput.h.

Referenced by RayTracingMeshOutput(), and setupEquationSystem().

◆ _output_data

const bool RayTracingMeshOutput::_output_data
protected

Whether or not to output all of the Ray's data.

Definition at line 57 of file RayTracingMeshOutput.h.

Referenced by RayTracingMeshOutput(), and setupEquationSystem().

◆ _output_data_names

const std::vector<std::string>* const RayTracingMeshOutput::_output_data_names
protected

Specific Ray data to output.

Definition at line 59 of file RayTracingMeshOutput.h.

Referenced by RayTracingMeshOutput(), and setupEquationSystem().

◆ _output_data_nodal

const bool RayTracingMeshOutput::_output_data_nodal
protected

Whether or not to output the Ray's data in a nodal, linear sense.

Definition at line 61 of file RayTracingMeshOutput.h.

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

◆ _pid_var

unsigned int RayTracingMeshOutput::_pid_var
private

The variable index in _sys for the Ray's processor id (if any)

Definition at line 114 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _processor_crossings_var

unsigned int RayTracingMeshOutput::_processor_crossings_var
private

The variable index in _sys for the Ray's processor crossings (if any)

Definition at line 116 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _ray_id_var

unsigned int RayTracingMeshOutput::_ray_id_var
private

The variable index in _sys for the Ray's ID (if any)

Definition at line 110 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _ray_starting_id_map

std::unordered_map<RayID, std::pair<dof_id_type, dof_id_type> > RayTracingMeshOutput::_ray_starting_id_map
private

The map from RayID to the starting element and node ID of the mesh element for said Ray.

Definition at line 132 of file RayTracingMeshOutput.h.

Referenced by buildIDMap(), and startingIDs().

◆ _segment_mesh

std::unique_ptr<MeshBase> RayTracingMeshOutput::_segment_mesh
protected

The mesh that contains the segments.

Definition at line 68 of file RayTracingMeshOutput.h.

Referenced by buildSegmentMesh(), fillFields(), output(), RayTracingExodus::outputMesh(), RayTracingNemesis::outputMesh(), and setupEquationSystem().

◆ _segmented_rays

bool RayTracingMeshOutput::_segmented_rays
private

Whether or not we have segmented rays.

Definition at line 136 of file RayTracingMeshOutput.h.

Referenced by buildSegmentMesh(), and setupEquationSystem().

◆ _study

const RayTracingStudy& RayTracingMeshOutput::_study
protected

◆ _sys

libMesh::ExplicitSystem* RayTracingMeshOutput::_sys
protected

The system that stores the field data.

Definition at line 72 of file RayTracingMeshOutput.h.

Referenced by fillFields(), output(), and setupEquationSystem().

◆ _trajectory_changes_var

unsigned int RayTracingMeshOutput::_trajectory_changes_var
private

The variable index in _sys for the Ray's trajectory changes (if any)

Definition at line 118 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().


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