https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RepeatableRayStudyBaseTest.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
11
14
17{
18 auto params = RepeatableRayStudy::validParams();
19
20 params.addParam<bool>("create_non_unique_id_rays",
21 "Create Rays on each processor with a non-unique ID");
22
23 params.addParam<processor_id_type>("create_additional_ray_pid",
24 "Create an additional Ray on the given processor");
25 params.addParam<processor_id_type>(
26 "create_non_replicated_id_ray_pid",
27 "Create a Ray with a non-replicated ID on the given processor");
28 params.addParam<processor_id_type>("create_non_replicated_ray_pid",
29 "Create a non-replicated Ray on the given processor");
30
31 params.addParam<bool>("define_no_rays", false, "Test defining no rays");
32 params.addParam<bool>("define_nullptr_ray", false, "Test defining a nullptr ray");
33 params.addParam<bool>(
34 "define_ray_with_starting_elem", false, "Test defining a ray with a starting element");
35
36 params.suppressParameter<std::vector<Real>>("max_distances");
37 params.suppressParameter<std::vector<Point>>("end_points");
38
39 return params;
40}
41
44{
45 auto params = RepeatableRayStudy::validParams();
46 params.set<bool>("_claim_after_define_rays") = false;
47 return params;
48}
49
54
60
61void
63{
64 if (getParam<bool>("define_no_rays"))
65 return;
66
68
69 if (getParam<bool>("define_nullptr_ray") && _rays.size())
70 _rays[0] = nullptr;
71
72 if (parameters().isParamSetByUser("create_non_unique_id_rays") &&
73 getParam<bool>("create_non_unique_id_rays"))
74 _rays.push_back(acquireCopiedRay(*_rays[0]));
75
76 if (parameters().isParamSetByUser("create_additional_ray_pid"))
77 {
78 const auto pid = getParam<processor_id_type>("create_additional_ray_pid");
79
80 mooseAssert(pid < n_processors(), "Invalid pid");
81 auto ray = acquireRegisteredRay("additional_ray");
82
83 if (pid == _pid)
84 {
85 ray->setStart(_rays[0]->currentPoint());
86 ray->setStartingDirection(_rays[0]->direction());
87 _rays.push_back(ray);
88 }
89 }
90
91 if (parameters().isParamSetByUser("create_non_replicated_id_ray_pid"))
92 {
93 const auto pid = getParam<processor_id_type>("create_non_replicated_id_ray_pid");
94
95 mooseAssert(pid < n_processors(), "Invalid pid");
96 auto ray = acquireRegisteredRay("non_replicated_ray");
97
98 if (pid == _pid)
99 {
100 ray->setStart(_rays[0]->currentPoint());
101 ray->setStartingDirection(_rays[0]->direction());
102 _rays[0] = ray;
103 }
104 }
105
106 if (parameters().isParamSetByUser("create_non_replicated_ray_pid"))
107 {
108 const auto pid = getParam<processor_id_type>("create_non_replicated_ray_pid");
109
110 mooseAssert(pid < n_processors(), "Invalid pid");
111
112 if (pid == _pid)
113 _rays[0]->setStartingMaxDistance(1);
114 }
115
116 if (getParam<bool>("define_ray_with_starting_elem"))
117 {
118 auto ray = acquireRegisteredRay("starting_elem_ray");
119 ray->setStart(Point(0, 0, 0), _mesh.queryElemPtr(0));
120 ray->setStartingDirection(Point(1, 0, 0));
121 _rays.push_back(ray);
122 }
123}
registerMooseObject("RayTracingTestApp", RepeatableRayStudyBaseTest)
const InputParameters & parameters() const
bool isParamSetByUser(const std::string &name) const
virtual Elem * queryElemPtr(const dof_id_type i)
std::shared_ptr< Ray > acquireCopiedRay(const Ray &ray)
Acquires a Ray that that is copied from another Ray within generateRays().
std::shared_ptr< Ray > acquireRegisteredRay(const std::string &name)
Acquires a Ray with a given name within generateRays().
MooseMesh & _mesh
The Mesh.
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once)
RepeatableRayStudyBaseTest(const InputParameters &parameters)
static InputParameters validParams()
void defineRays() override
Entry point for the user to create Rays.
std::vector< std::shared_ptr< Ray > > & _rays
Vector of Rays that the user will fill into in defineRays() (restartable)
RepeatableRayStudyDefineNoClaimTest(const InputParameters &params)
A RayTracingStudy in which the user defines a set of Rays that can be traced repeatedly.
static InputParameters validParams()
virtual void defineRays() override
Entry point for the user to create Rays.
processor_id_type n_processors() const