https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
17
20{
22
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
63void
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
83Real
85{
86 RayID id;
87 if (_ray_name)
88 {
89 id = _study.registeredRayID(*_ray_name, /* graceful = */ true);
90 if (id == Ray::INVALID_RAY_ID)
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}
registerMooseObject("RayTracingApp", RayDataValue)
unsigned long int RayID
Type for a Ray's ID.
Definition Ray.h:44
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)
void addClassDescription(const std::string &doc_string)
const std::string & type() const
std::string typeAndName() const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
Obtains a Ray data or aux data value from a banked ray.
virtual Real getValue() const override
static InputParameters validParams()
virtual void initialize() override
const RayID *const _ray_id
The provided Ray ID (if any)
const RayTracingStudy & _study
The RayTracingStudy.
unsigned int _ray_data_index
The index into the Ray's data that the desired RayVariable is at.
const bool _aux
Whether or not to get auxiliary data (if false, get standard data)
RayDataValue(const InputParameters &parameters)
const std::string *const _ray_name
The provided Ray name (if any)
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
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.
RayDataIndex getRayDataIndex(const std::string &name, const bool graceful=false) const
Gets the index associated with a registered value in the Ray data.
bool bankRaysOnCompletion() const
Whether or not to bank Rays on completion.
RayID registeredRayID(const std::string &name, const bool graceful=false) const
Gets the ID of a registered ray.
RayData getBankedRayAuxData(const RayID ray_id, const RayDataIndex index) const
Gets the data value for a banked ray with a given ID.
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
static const RayID INVALID_RAY_ID
Invalid Ray ID.
Definition Ray.h:214