https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | 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
 
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 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
 
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 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
 
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 ExecFlagEnum getDefaultExecFlagEnum ()
 
static void addDeprecatedInputParameters (InputParameters &params)
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

virtual void outputMesh ()=0
 Output the mesh - to be overridden. More...
 
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 ()
 
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
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) 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 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
 
virtual void addUserObjectDependencyHelper (const UserObject &) 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. More...
 
const bool _output_data
 Whether or not to output all of the Ray's data. More...
 
const std::vector< std::string > *const _output_data_names
 Specific Ray data to output. More...
 
const bool _output_data_nodal
 Whether or not to output the Ray's data in a nodal, linear sense. More...
 
const bool _output_aux_data
 Whether or not to output the Ray's aux data. More...
 
const std::vector< std::string > *const _output_aux_data_names
 Specific Ray Aux data to output. More...
 
std::unique_ptr< MeshBase > _segment_mesh
 The mesh that contains the segments. More...
 
std::unique_ptr< libMesh::EquationSystems_es
 The EquationSystems. More...
 
libMesh::ExplicitSystem_sys
 The system that stores the field data. More...
 
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
 
const Real _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
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
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. More...
 
void buildIDMap ()
 Builds a map for each Ray to starting element and node ID for the EDGE2 mesh that will represent said Ray. More...
 
void buildSegmentMesh ()
 Build the mesh that contains the ray tracing segments. More...
 
void setupEquationSystem ()
 Setup the equation system that stores the segment-wise field data. More...
 
void fillFields ()
 Fill the Ray field data. More...
 
dof_id_type neededNodes (const TraceData &trace_data) const
 Gets the number of nodes needed to represent a given trace. More...
 
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. More...
 

Private Attributes

unsigned int _ray_id_var
 The variable index in _sys for the Ray's ID (if any) More...
 
unsigned int _intersections_var
 The variable index in _sys for the intersection ID (if any) More...
 
unsigned int _pid_var
 The variable index in _sys for the Ray's processor id (if any) More...
 
unsigned int _processor_crossings_var
 The variable index in _sys for the Ray's processor crossings (if any) More...
 
unsigned int _trajectory_changes_var
 The variable index in _sys for the Ray's trajectory changes (if any) More...
 
std::vector< std::pair< RayDataIndex, unsigned int > > _data_vars
 The ray data index -> variable index map. More...
 
std::vector< std::pair< RayDataIndex, unsigned int > > _aux_data_vars
 The ray aux data index -> variable index map. More...
 
BoundingBox _bbox
 The bounding box for this processor. More...
 
std::vector< BoundingBox > _inflated_bboxes
 The inflated bounding boxes for all processors. More...
 
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) More...
 
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. More...
 
dof_id_type _max_node_id
 The max node ID for the ray tracing mesh for creating unique elem IDs. More...
 
bool _segmented_rays
 Whether or not we have segmented rays. More...
 

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 56 of file RayTracingMeshOutput.C.

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

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 653 of file RayTracingMeshOutput.C.

Referenced by output().

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

◆ 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 150 of file RayTracingMeshOutput.C.

Referenced by buildSegmentMesh().

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

◆ buildSegmentMesh()

void RayTracingMeshOutput::buildSegmentMesh ( )
private

Build the mesh that contains the ray tracing segments.

Definition at line 266 of file RayTracingMeshOutput.C.

Referenced by output().

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

◆ filename()

std::string RayTracingMeshOutput::filename ( )
overridevirtual

Reimplemented from FileOutput.

Definition at line 102 of file RayTracingMeshOutput.C.

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

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

◆ fillFields()

void RayTracingMeshOutput::fillFields ( )
private

Fill the Ray field data.

Definition at line 574 of file RayTracingMeshOutput.C.

Referenced by output().

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

◆ 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 706 of file RayTracingMeshOutput.C.

Referenced by buildIDMap().

707 {
709  return trace_data._intersections + trace_data._point_data.size();
710  return trace_data._processor_crossings + trace_data._trajectory_changes +
711  trace_data._point_data.size();
712 }
bool segmentsOnCacheTraces() const
Whether or not to cache individual element segments when _cache_traces = true.
const RayTracingStudy & _study
The RayTracingStudy.
const unsigned long int _intersections
The number of intersections thus far.
Definition: TraceData.h:70
const unsigned int _processor_crossings
Number of processor crossings thus far.
Definition: TraceData.h:72
const unsigned int _trajectory_changes
Number of trajectory changes thus far.
Definition: TraceData.h:74
std::vector< TracePointData > _point_data
The data for each point along the track.
Definition: TraceData.h:78

◆ output()

void RayTracingMeshOutput::output ( )
overridevirtual

Implements FileOutput.

Definition at line 118 of file RayTracingMeshOutput.C.

Referenced by filename().

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

◆ 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 488 of file RayTracingMeshOutput.C.

Referenced by output().

489 {
490  TIME_SECTION("setupEquationSystem", 3, "Setting Up Ray Tracing MeshOutput Equation System");
491 
492  _es = std::make_unique<EquationSystems>(*_segment_mesh);
493  _sys = &_es->add_system<libMesh::ExplicitSystem>("sys");
494  _data_vars.clear();
495  _aux_data_vars.clear();
496 
497  // Add variables for the basic properties if enabled
503  for (auto & prop : _pars.get<MultiMooseEnum>("output_properties"))
504  switch (prop)
505  {
506  case 0: // ray_id (stationary and segments)
507  _ray_id_var = _sys->add_variable("ray_id", CONSTANT, MONOMIAL);
508  break;
509  case 1: // intersections (segments only)
510  if (_segmented_rays)
511  _intersections_var = _sys->add_variable("intersections", CONSTANT, MONOMIAL);
512  break;
513  case 2: // pid (stationary and segments)
514  _pid_var = _sys->add_variable("pid", CONSTANT, MONOMIAL);
515  break;
516  case 3: // processor_crossings (segments only)
517  if (_segmented_rays)
518  _processor_crossings_var = _sys->add_variable("processor_crossings", CONSTANT, MONOMIAL);
519  break;
520  case 4: // trajectory_changes (segments only)
521  if (_segmented_rays)
522  _trajectory_changes_var = _sys->add_variable("trajectory_changes", CONSTANT, MONOMIAL);
523  break;
524  default:
525  mooseError("Invalid property");
526  }
527 
528  const auto get_data_vars = [this](const bool aux)
529  {
530  // The data index -> variable result
531  std::vector<std::pair<RayDataIndex, unsigned int>> vars;
532 
533  const auto from_names =
536 
537  // Nothing to output
538  if (!from_names)
539  return vars;
540 
541  const auto output_data_nodal = aux ? false : _output_data_nodal;
542 
543  for (const auto & name : *from_names)
544  {
545  const auto data_index =
547  if (data_index == Ray::INVALID_RAY_DATA_INDEX)
548  {
549  const std::string names_param = aux ? "output_aux_data_names" : "output_data_names";
550  const std::string data_prefix = aux ? "aux " : "";
551  paramError(names_param, "The ray ", data_prefix, "data '", name, "' is not registered");
552  }
553 
554  const std::string var_prefix = aux ? "aux_" : "";
555  if (output_data_nodal)
556  _sys->add_variable(var_prefix + name, FIRST, LAGRANGE);
557  else
558  _sys->add_variable(var_prefix + name, CONSTANT, MONOMIAL);
559  const auto var_num = _sys->variable_number(var_prefix + name);
560  vars.emplace_back(data_index, var_num);
561  }
562 
563  return vars;
564  };
565 
566  _data_vars = get_data_vars(false);
567  _aux_data_vars = get_data_vars(true);
568 
569  // All done
570  _es->init();
571 }
static const RayDataIndex INVALID_RAY_DATA_INDEX
Invalid index into a Ray&#39;s data.
Definition: Ray.h:200
const bool _output_data
Whether or not to output all of the Ray&#39;s data.
const unsigned int invalid_uint
const bool _output_data_nodal
Whether or not to output the Ray&#39;s data in a nodal, linear sense.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const std::vector< std::string > & rayDataNames() const
The Ray data names.
char ** vars
std::vector< std::pair< RayDataIndex, unsigned int > > _data_vars
The ray data index -> variable index map.
const RayTracingStudy & _study
The RayTracingStudy.
bool _segmented_rays
Whether or not we have segmented rays.
virtual const std::string & name() const
RayDataIndex getRayAuxDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray aux data.
unsigned int variable_number(std::string_view var) const
const bool _output_aux_data
Whether or not to output the Ray&#39;s aux data.
std::vector< std::pair< RayDataIndex, unsigned int > > _aux_data_vars
The ray aux data index -> variable index map.
const std::vector< std::string > *const _output_data_names
Specific Ray data to output.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
const std::vector< std::string > *const _output_aux_data_names
Specific Ray Aux data to output.
std::unique_ptr< libMesh::EquationSystems > _es
The EquationSystems.
void paramError(const std::string &param, Args... args) const
unsigned int _intersections_var
The variable index in _sys for the intersection ID (if any)
const std::vector< std::string > & rayAuxDataNames() const
The Ray aux data names.
unsigned int _ray_id_var
The variable index in _sys for the Ray&#39;s ID (if any)
libMesh::ExplicitSystem * _sys
The system that stores the field data.
void mooseError(Args &&... args) const
const InputParameters & _pars
unsigned int _processor_crossings_var
The variable index in _sys for the Ray&#39;s processor crossings (if any)
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
unsigned int _pid_var
The variable index in _sys for the Ray&#39;s processor id (if any)
unsigned int _trajectory_changes_var
The variable index in _sys for the Ray&#39;s trajectory changes (if any)

◆ 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 688 of file RayTracingMeshOutput.C.

Referenced by buildSegmentMesh(), and fillFields().

691 {
692  const auto [begin_node_id, begin_elem_id] = _ray_starting_id_map.at(trace_data._ray_id);
693 
694  const auto offset =
695  trace_data.stationary()
696  ? 1
698  ? trace_data._intersections
699  : (trace_data._processor_crossings + trace_data._trajectory_changes));
700 
701  start_node_id = begin_node_id + offset;
702  start_elem_id = begin_elem_id + offset;
703 }
bool stationary() const
Definition: TraceData.h:59
bool segmentsOnCacheTraces() const
Whether or not to cache individual element segments when _cache_traces = true.
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...
const RayTracingStudy & _study
The RayTracingStudy.
const unsigned long int _intersections
The number of intersections thus far.
Definition: TraceData.h:70
const unsigned int _processor_crossings
Number of processor crossings thus far.
Definition: TraceData.h:72
const unsigned int _trajectory_changes
Number of trajectory changes thus far.
Definition: TraceData.h:74
const RayID _ray_id
The Ray ID.
Definition: TraceData.h:68

◆ validParams()

InputParameters RayTracingMeshOutput::validParams ( )
static

Definition at line 30 of file RayTracingMeshOutput.C.

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

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

Referenced by fillFields(), and setupEquationSystem().

◆ _bbox

BoundingBox RayTracingMeshOutput::_bbox
private

The bounding box for this processor.

Definition at line 122 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 117 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().

◆ _es

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

The EquationSystems.

Definition at line 67 of file RayTracingMeshOutput.h.

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

◆ _inflated_bboxes

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

The inflated bounding boxes for all processors.

Definition at line 124 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 126 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 109 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 131 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 60 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 62 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 54 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 56 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 58 of file RayTracingMeshOutput.h.

Referenced by fillFields(), RayTracingNemesis::outputMesh(), RayTracingExodus::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 111 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 113 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 107 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 129 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 65 of file RayTracingMeshOutput.h.

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

◆ _segmented_rays

bool RayTracingMeshOutput::_segmented_rays
private

Whether or not we have segmented rays.

Definition at line 133 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 69 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 115 of file RayTracingMeshOutput.h.

Referenced by fillFields(), and setupEquationSystem().


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