https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TestRay.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 "TestRay.h"
11
12registerMooseObject("RayTracingTestApp", TestRay);
13
16{
17 auto params = RayTracingStudy::validParams();
18
19 params.addParam<bool>("at_end_without_set", false, "Test Ray::atEnd() without the end being set");
20 params.addParam<bool>(
21 "end_point_without_set", false, "Test Ray::endPoint() without the end being set");
22 params.addParam<bool>(
23 "set_start_again", false, "Test setting a Ray's start point multiple times");
24 params.addParam<bool>(
25 "set_direction_again", false, "Test setting a Ray's direction multiple times");
26 params.addParam<bool>("set_start_fail_bbox",
27 false,
28 "Test setting a Ray's start point to a point that fails the bbox check");
29 params.addParam<bool>("set_side_without_elem",
30 false,
31 "Test setting a Ray's incoming side without a starting element");
32 params.addParam<bool>(
33 "set_invalid_side", false, "Test setting a Ray's incoming side to an invalid one");
34 params.addParam<bool>(
35 "set_bad_side", false, "Test setting a Ray's incoming side to a wrong side");
36 params.addParam<bool>(
37 "set_bad_start",
38 false,
39 "Test setting a Ray's start point to one that is not within the starting element");
40 params.addParam<bool>(
41 "set_direction_before_start", false, "Test setting a Ray's direction before its start point");
42 params.addParam<bool>(
43 "set_zero_direction", false, "Test setting a Ray's direction to the zero vector");
44 params.addParam<bool>(
45 "set_end_before_start", false, "Test setting a Ray's end point before its start point");
46 params.addParam<bool>(
47 "set_end_equal_start", false, "Test setting a Ray's end point to its start point");
48 params.addParam<bool>("set_end_with_direction",
49 false,
50 "Test setting a Ray's end point after setting its direction");
51 params.addParam<bool>("set_distance_with_end",
52 false,
53 "Test setting a Ray's max distance after setting its end point");
54 params.addParam<bool>("set_end_with_distance",
55 false,
56 "Test setting a Ray's end point after setting its max distance");
57 params.addParam<bool>("set_end_fail_bbox",
58 false,
59 "Test setting a Ray's end point to a point that fails the bbox check");
60 params.addParam<bool>("set_distance_before_start",
61 false,
62 "Test setting a Ray's max distance before its start point");
63 params.addParam<bool>(
64 "set_distance_negative", false, "Test setting a Ray's max distance to a negative value");
65 params.addParam<bool>(
66 "set_start_inactive", false, "Tests setting a Ray's starting element to an inactive element");
67 params.addParam<bool>("set_stationary_before_start",
68 false,
69 "Test setting a Ray as stationary before its start point");
70 params.addParam<bool>("set_stationary_with_direction",
71 false,
72 "Test setting a Ray as stationary after setting its direction");
73 params.addParam<bool>("set_stationary_with_end",
74 false,
75 "Test setting a Ray as stationary after setting its endpoint");
76 params.set<bool>("_use_ray_registration") = false;
77
78 return params;
79}
80
81TestRay::TestRay(const InputParameters & parameters) : RayTracingStudy(parameters) {}
82
83void
85{
86 if (_mesh.getMesh().n_local_elem() != 0)
87 {
88 const Elem * elem = *_mesh.getActiveLocalElementRange()->begin();
89
90 auto ray = acquireRay();
91
92 if (getParam<bool>("set_distance_before_start"))
93 ray->setStartingMaxDistance(1);
94 if (getParam<bool>("set_stationary_before_start"))
95 ray->setStationary();
96 if (getParam<bool>("at_end_without_set"))
97 ray->atEnd();
98 if (getParam<bool>("end_point_without_set"))
99 ray->endPoint();
100 if (getParam<bool>("set_start_fail_bbox"))
101 ray->setStart(Point(1e6, 1e6, 1e6));
102 if (getParam<bool>("set_side_without_elem"))
103 ray->setStart(elem->vertex_average(), nullptr, 0);
104 if (getParam<bool>("set_invalid_side"))
105 ray->setStart(elem->vertex_average(), elem, 100);
106 if (getParam<bool>("set_bad_side"))
107 ray->setStart(elem->vertex_average(), elem, 0);
108 if (getParam<bool>("set_direction_before_start"))
109 ray->setStartingDirection(Point(1, 0, 0));
110 if (getParam<bool>("set_bad_start"))
111 {
112 const Elem * another_elem = elem->neighbor_ptr(0);
113 if (!another_elem)
114 another_elem = elem->neighbor_ptr(1);
115 ray->setStart(elem->vertex_average(), another_elem);
116 }
117 if (getParam<bool>("set_end_before_start"))
118 ray->setStartingEndPoint(elem->point(0));
119 if (getParam<bool>("set_start_inactive"))
120 {
121 for (const auto & inactive_elem : meshBase().element_ptr_range())
122 if (!inactive_elem->active())
123 ray->setStart(inactive_elem->true_centroid(), inactive_elem);
124 }
125
126 ray->setStart(elem->vertex_average(), elem);
127
128 if (getParam<bool>("set_start_again"))
129 ray->setStart(1.01 * elem->vertex_average());
130 if (getParam<bool>("set_direction_again"))
131 {
132 ray->setStartingDirection(Point(1, 0, 0));
133 ray->setStartingDirection(Point(-1, 0, 0));
134 }
135 if (getParam<bool>("set_zero_direction"))
136 ray->setStartingDirection(Point(0, 0, 0));
137 if (getParam<bool>("set_end_equal_start"))
138 ray->setStartingEndPoint(ray->currentPoint());
139 if (getParam<bool>("set_end_with_direction"))
140 {
141 ray->setStartingDirection(Point(1, 0, 0));
142 ray->setStartingEndPoint(elem->point(0));
143 }
144 if (getParam<bool>("set_distance_with_end"))
145 {
146 ray->setStartingEndPoint(elem->point(0));
147 ray->setStartingMaxDistance(1);
148 }
149 if (getParam<bool>("set_end_with_distance"))
150 {
151 ray->setStartingMaxDistance(1);
152 ray->setStartingEndPoint(elem->point(0));
153 }
154 if (getParam<bool>("set_end_fail_bbox"))
155 ray->setStartingEndPoint(Point(1e6, 1e6, 1e6));
156 if (getParam<bool>("set_distance_negative"))
157 ray->setStartingMaxDistance(-1);
158 if (getParam<bool>("set_stationary_with_direction"))
159 {
160 ray->setStartingDirection(Point(1, 0, 0));
161 ray->setStationary();
162 }
163 if (getParam<bool>("set_stationary_with_end"))
164 {
165 ray->setStartingEndPoint(elem->point(0));
166 ray->setStationary();
167 }
168 }
169}
registerMooseObject("RayTracingTestApp", TestRay)
MeshBase & getMesh()
const libMesh::ConstElemRange * getActiveLocalElementRange()
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
MeshBase & meshBase() const
Access to the libMesh MeshBase.
static InputParameters validParams()
MooseMesh & _mesh
The Mesh.
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
static InputParameters validParams()
Definition TestRay.C:15
void generateRays() override final
Subclasses should override this to determine how to generate Rays.
Definition TestRay.C:84
TestRay(const InputParameters &parameters)
Definition TestRay.C:81
const_iterator begin() const