https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TestRayDataStudy.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#include "TestRayDataStudy.h"
11
13
16{
17 auto params = LotsOfRaysRayStudy::validParams();
18 params.addRequiredParam<unsigned int>("data_size", "Size for the test Ray data");
19 params.addRequiredParam<unsigned int>("aux_data_size", "Size for the test aux Ray data");
20 return params;
21}
22
24 : LotsOfRaysRayStudy(parameters),
25 _data_size(getParam<unsigned int>("data_size")),
26 _aux_data_size(getParam<unsigned int>("aux_data_size"))
27{
29 for (unsigned int i = 0; i < _data_size; ++i)
30 _data_indices[i] = registerRayData("test_data_" + std::to_string(i));
31
33 for (unsigned int i = 0; i < _aux_data_size; ++i)
34 _aux_data_indices[i] = registerRayAuxData("test_aux_data_" + std::to_string(i));
35
36 _actual_start_indices.resize(3);
37 for (unsigned int i = 0; i < 3; ++i)
38 _actual_start_indices[i] = registerRayAuxData("actual_start_" + std::to_string(i));
39}
40
42TestRayDataStudy::dataValue(const unsigned int i, const Ray & ray) const
43{
44 Point actual_start;
45 actual_start(0) = ray.auxData(_actual_start_indices[0]);
46 actual_start(1) = ray.auxData(_actual_start_indices[1]);
47 actual_start(2) = ray.auxData(_actual_start_indices[2]);
48
49 const Point bounding_box_centroid = 0.5 * (boundingBox().min() + boundingBox().max());
50 const RayData data_start =
51 (actual_start - bounding_box_centroid).norm() * (RayData)(i + 1) / (RayData)_data_size;
52
53 return data_start + dataValueChange(i, ray.distance());
54}
55
57TestRayDataStudy::dataValueChange(const unsigned int i, const Real distance) const
58{
59 return 0.3 * (RayData)(i + 1) * (RayData)_data_size * distance;
60}
61
63TestRayDataStudy::auxDataValue(const unsigned int i, const Ray & ray) const
64{
65 Point actual_start;
66 actual_start(0) = ray.auxData(_actual_start_indices[0]);
67 actual_start(1) = ray.auxData(_actual_start_indices[1]);
68 actual_start(2) = ray.auxData(_actual_start_indices[2]);
69
70 return (actual_start - boundingBox().min()).norm() * (RayData)(i + 1) * (RayData)_data_size;
71}
72
73void
75{
76 for (const std::shared_ptr<Ray> & ray : _rays)
77 {
78 for (unsigned int i = 0; i < 3; ++i)
79 ray->auxData(_actual_start_indices[i]) = ray->currentPoint()(i);
80
81 for (unsigned int i = 0; i < _data_size; ++i)
82 ray->data(_data_indices[i]) = dataValue(i, *ray);
83
84 for (unsigned int i = 0; i < _aux_data_size; ++i)
85 ray->auxData(_aux_data_indices[i]) = auxDataValue(i, *ray);
86 }
87}
88
89void
90TestRayDataStudy::onCompleteRay(const std::shared_ptr<Ray> & ray)
91{
93
94 const Ray & const_ray = *ray;
95
96 for (unsigned int i = 0; i < _data_size; ++i)
97 if (!MooseUtils::absoluteFuzzyEqual(const_ray.data(_data_indices[i]), dataValue(i, const_ray)))
98 mooseError(_name, ": Incorrect expected data");
99
100 for (unsigned int i = 0; i < _aux_data_size; ++i)
101 if (!MooseUtils::absoluteFuzzyEqual(const_ray.auxData(_aux_data_indices[i]),
102 auxDataValue(i, const_ray)))
103 mooseError(_name, ": Incorrect expected aux data");
104}
float RayData
Type for a Ray's data.
Definition Ray.h:47
registerMooseObject("RayTracingTestApp", TestRayDataStudy)
void ErrorVector unsigned int
A RayTracingStudy used for generating a lot of rays for testing purposes.
static InputParameters validParams()
void mooseError(Args &&... args) const
const std::string & _name
RayDataIndex registerRayAuxData(const std::string &name)
Register a value to be filled in the aux data on a Ray with a given name.
RayDataIndex registerRayData(const std::string &name)
Register a value to be filled in the data on a Ray with a given name.
virtual void onCompleteRay(const std::shared_ptr< Ray > &ray)
Entry point for acting on a ray when it is completed (shouldContinue() == false)
const BoundingBox & boundingBox() const
Get the nodal bounding box for the domain.
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58
std::vector< RayData > & auxData()
Gets a writeable reference to the Ray's auxilary data.
Definition Ray.C:451
Real distance() const
Gets the distance this Ray has traveled.
Definition Ray.h:512
std::vector< RayData > & data()
Gets a writeable reference to the Ray's data.
Definition Ray.C:417
std::vector< std::shared_ptr< Ray > > & _rays
Vector of Rays that the user will fill into in defineRays() (restartable)
Test Ray study that generates a lot of Rays and sets data/aux data with a predictable pattern in conj...
std::vector< RayDataIndex > _aux_data_indices
RayData dataValueChange(const unsigned int i, const Real distance) const
std::vector< RayDataIndex > _actual_start_indices
const std::size_t _aux_data_size
virtual void onCompleteRay(const std::shared_ptr< Ray > &ray) override
Entry point for acting on a ray when it is completed (shouldContinue() == false)
RayData dataValue(const unsigned int i, const Ray &ray) const
static InputParameters validParams()
TestRayDataStudy(const InputParameters &parameters)
const std::size_t _data_size
std::vector< RayDataIndex > _data_indices
virtual void modifyRays() override
Insertion point for after _rays is defined for other derived test studies to modify the Rays.
RayData auxDataValue(const unsigned int i, const Ray &ray) const
Real distance(const Point &p)