https://mooseframework.inl.gov
RayDataValue.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // MOOSE includes
11 #include "RayDataValue.h"
12 
13 // Local includes
14 #include "RayTracingStudy.h"
15 
16 registerMooseObject("RayTracingApp", RayDataValue);
17 
20 {
22 
23  params.addClassDescription(
24  "Obtains a value from the data or aux data of a Ray after tracing has been completed.");
25 
26  params.addRequiredParam<UserObjectName>("study", "The RayTracingStudy that owns the Ray");
27  params.addParam<RayID>("ray_id",
28  "The ID of the Ray to get the value from. This or 'ray_id' must be set.");
29  params.addParam<std::string>(
30  "ray_name", "Name of the Ray to get the value from. This or 'ray_name' must be set.");
31  params.addRequiredParam<std::string>("data_name", "The name of the data to extract from the Ray");
32  params.addParam<bool>("aux", false, "Whether or not the data is an auxiliary value");
33 
34  return params;
35 }
36 
38  : GeneralPostprocessor(parameters),
39  _study(getUserObject<RayTracingStudy>("study")),
40  _aux(getParam<bool>("aux")),
41  _ray_name(parameters.isParamSetByUser("ray_name") ? &getParam<std::string>("ray_name")
42  : nullptr),
43  _ray_id(parameters.isParamSetByUser("ray_id") ? &getParam<RayID>("ray_id") : nullptr)
44 {
45  if (_ray_id && _ray_name)
46  paramError("ray_id", "Either 'ray_id' or 'ray_name' must be set, but not both");
47  if (!_ray_id && !_ray_name)
48  mooseError("Must have either the 'ray_id' or the 'ray_name' param set.");
49 
51  paramError("study",
53  " does not support Ray registration.\n\nThis is controlled by the "
54  "'_use_ray_registration' private param within the study.");
55 
57  paramError("study",
59  " does not bank Rays on completion.\n\nThis is controlled by the "
60  "'_bank_rays_on_completion' private param within the study.");
61 }
62 
63 void
65 {
66  // Get the index for the data on the ray requested
67  const auto & data_name = getParam<std::string>("data_name");
68  if (_aux)
69  _ray_data_index = _study.getRayAuxDataIndex(data_name, /* graceful = */ true);
70  else
71  _ray_data_index = _study.getRayDataIndex(data_name, /* graceful = */ true);
73  paramError("ray_name",
74  "The ",
76  " does not have Ray ",
77  (_aux ? "aux " : ""),
78  "data associated with the name '",
79  data_name,
80  "'");
81 }
82 
83 Real
85 {
86  RayID id;
87  if (_ray_name)
88  {
89  id = _study.registeredRayID(*_ray_name, /* graceful = */ true);
90  if (id == Ray::INVALID_RAY_ID)
91  mooseError(type(),
92  " '",
93  name(),
94  "': Could not find a registered Ray with the name '",
95  *_ray_name,
96  "'");
97  }
98  else
99  id = *_ray_id;
100 
101  // This gathers the value from the proc that killed the Ray we're looking for
102  if (_aux)
104  else
106 }
const RayID *const _ray_id
The provided Ray ID (if any)
Definition: RayDataValue.h:44
static const RayDataIndex INVALID_RAY_DATA_INDEX
Invalid index into a Ray&#39;s data.
Definition: Ray.h:200
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
RayData getBankedRayData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
bool useRayRegistration() const
Whether or not ray registration is being used.
virtual Real getValue() const override
Definition: RayDataValue.C:84
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
RayDataIndex getRayAuxDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray aux data.
RayDataValue(const InputParameters &parameters)
Definition: RayDataValue.C:37
static InputParameters validParams()
const std::string & type() const
const std::string *const _ray_name
The provided Ray name (if any)
Definition: RayDataValue.h:42
std::string typeAndName() const
void paramError(const std::string &param, Args... args) const
Obtains a Ray data or aux data value from a banked ray.
Definition: RayDataValue.h:22
const RayTracingStudy & _study
The RayTracingStudy.
Definition: RayDataValue.h:36
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _aux
Whether or not to get auxiliary data (if false, get standard data)
Definition: RayDataValue.h:39
static InputParameters validParams()
Definition: RayDataValue.C:19
virtual void initialize() override
Definition: RayDataValue.C:64
bool bankRaysOnCompletion() const
Whether or not to bank Rays on completion.
RayData getBankedRayAuxData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
RayID registeredRayID(const std::string &name, const bool graceful=false) const
Gets the ID of a registered ray.
registerMooseObject("RayTracingApp", RayDataValue)
unsigned int _ray_data_index
The index into the Ray&#39;s data that the desired RayVariable is at.
Definition: RayDataValue.h:48
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
static const RayID INVALID_RAY_ID
Invalid Ray ID.
Definition: Ray.h:202
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...