19 params.addClassDescription(
"A ray tracing study that generates rays from vector of user-input " 20 "start points and end points/directions.");
22 params.addRequiredParam<std::vector<std::string>>(
"names",
"Unique names for the Rays");
24 params.addRequiredParam<std::vector<Point>>(
"start_points",
"The points to start Rays from");
25 params.addParam<std::vector<Point>>(
"directions",
26 "The directions to spawn Rays in (they do not need to be " 27 "normalized to 1). Use either this parameter " 28 "or the end_points parameter, but not both!");
29 params.addParam<std::vector<Point>>(
"end_points",
30 "The points where Rays should end. Use either this parameter " 31 "or the directions parameter, but not both!");
32 params.addParam<std::vector<Real>>(
34 "The maximum distances that each Ray can travel before it is killed internally after " 35 "RayKernel execution. This can ONLY be used when the 'directions' parameter is used. " 36 "When this is not set, the Rays must be killed by RayKernels, RayBCs, or the global " 37 " max distance parameter, 'ray_max_distance' (applies to all Rays)");
39 params.addParamNamesToGroup(
"start_points directions end_points max_distances",
"Trajectory");
41 params.addParam<std::vector<std::string>>(
43 "The Ray data names to register. If 'initial_ray_data' is set, these data names will be " 44 "associated with said initial values. Otherwise, they will be set to zero.");
45 params.addParam<std::vector<std::vector<Real>>>(
47 "The initial Ray data to set for each Ray. You must have size(ray_data_names) entries for " 48 "each Ray defined by 'names'. The data for each Ray should be separated by ';'.");
49 params.addParam<std::vector<std::string>>(
51 "The Ray aux data names to register. If 'initial_ray_aux_data' is set, these aux data names " 52 "will be associated with said initial values. Otherwise, they will be set to zero.");
53 params.addParam<std::vector<std::vector<Real>>>(
54 "initial_ray_aux_data",
55 "The initial Ray aux data to set for each Ray. You must have size(ray_aux_data_names) " 57 "for each Ray defined by 'names'. The data for each Ray should be separated by ';'.");
59 params.addParamNamesToGroup(
60 "ray_data_names initial_ray_data ray_aux_data_names initial_ray_aux_data",
"Ray Data");
67 _names(getParam<
std::vector<
std::string>>(
"names")),
68 _start_points(getParam<
std::vector<Point>>(
"start_points")),
69 _end_points(isParamValid(
"end_points") ? &getParam<
std::vector<Point>>(
"end_points") : nullptr),
70 _directions(isParamValid(
"directions") ? &getParam<
std::vector<Point>>(
"directions") : nullptr),
71 _max_distances(isParamValid(
"max_distances") ? &getParam<
std::vector<
Real>>(
"max_distances")
73 _ray_data_indices(isParamValid(
"ray_data_names")
74 ? registerRayData(getParam<
std::vector<
std::string>>(
"ray_data_names"))
76 _initial_ray_data(isParamValid(
"initial_ray_data")
77 ? &getParam<
std::vector<
std::vector<
Real>>>(
"initial_ray_data")
79 _ray_aux_data_indices(
80 isParamValid(
"ray_aux_data_names")
81 ? registerRayAuxData(getParam<
std::vector<
std::string>>(
"ray_aux_data_names"))
83 _initial_ray_aux_data(isParamValid(
"initial_ray_aux_data")
84 ? &getParam<
std::vector<
std::vector<
Real>>>(
"initial_ray_aux_data")
88 paramError(
"directions",
"Can only use 'directions' or 'end_points', but not both");
90 mooseError(
"Must set 'end_points' or 'directions'");
92 paramError(
"start_points",
"Not the same size as names");
94 paramError(
"directions",
"Not the same size as names");
99 "Can only be used when trajectories are set with the 'directions' parameter");
101 paramError(
"max_distances",
"Must be the same size as 'start_points'");
104 paramError(
"max_distances",
"Values must be positive");
107 paramError(
"end_points",
"Not the same size as names");
110 const auto check_data = [
this](
const bool aux)
113 const std::string param_prefix = aux ?
"aux_" :
"";
118 const std::string initial_data_param =
"initial_ray_" + param_prefix +
"data";
119 const std::string names_param =
"ray_" + param_prefix +
"data_names";
123 const std::string error_prefix = aux ?
"Aux data " :
"Data ";
124 if (initial_data->size() !=
_names.size())
128 initial_data->size(),
129 " ray(s) was provided, but ",
131 " ray(s) were defined");
133 if ((*initial_data)[i].size() != indices.size())
140 "') is not the size of '",
145 paramError(initial_data_param,
"Can only be used if '" + names_param +
"' is set");
155 for (std::size_t i = 0; i <
_names.size(); ++i)
166 const auto set_data = [
this, &ray, &i](
const bool aux)
172 mooseAssert(data->size() ==
_names.size(),
"Size mismatch");
173 mooseAssert((*data)[i].size() == indices.size(),
"Size mismatch");
174 for (
const auto index_i : indices)
176 const auto data_index = indices[index_i];
177 const auto value = (*data)[i][index_i];
179 ray->auxData(data_index) =
value;
181 ray->data(data_index) =
value;
192 _rays.emplace_back(std::move(ray));
const std::vector< RayDataIndex > _ray_aux_data_indices
The Ray aux data indices (if defined)
const std::vector< Point > _start_points
The points to start the Rays from.
const std::vector< std::vector< Real > > *const _initial_ray_aux_data
The initial Ray data to set (if defined)
std::shared_ptr< Ray > acquireRegisteredRay(const std::string &name)
Acquires a Ray with a given name within generateRays().
registerMooseObject("RayTracingApp", RepeatableRayStudy)
RepeatableRayStudy(const InputParameters ¶meters)
unsigned int RayDataIndex
Type for the index into the data and aux data on a Ray.
const std::vector< std::vector< Real > > *const _initial_ray_data
The initial Ray data to set (if defined)
const std::vector< Point > *const _directions
The Ray directions (if defined)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const std::vector< std::string > _names
The Ray names.
void paramError(const std::string ¶m, Args... args) const
const std::vector< RayDataIndex > _ray_data_indices
The Ray data indices (if defined)
static InputParameters validParams()
virtual void defineRays() override
Entry point for the user to create Rays.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
std::vector< std::shared_ptr< Ray > > & _rays
Vector of Rays that the user will fill into in defineRays() (restartable)
const std::vector< Real > *const _max_distances
The Ray max distances (if defined)
A RayTracingStudy in which the user defines a set of Rays that can be traced repeatedly.
static InputParameters validParams()
A RayTracingStudy that generates and traces Rays repeatedly that a user defines only once...
auto index_range(const T &sizable)
const std::vector< Point > *const _end_points
The Ray end points (if defined)