https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ChangeRayRayKernelTest.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
12#include "libmesh/remote_elem.h"
13
15
18{
19 auto params = GeneralRayKernel::validParams();
20 params.addParam<std::string>("data_name", "Name of the data to change");
21 params.addParam<Real>("add_value", 0, "Value to add to the data");
22 params.addParam<Real>("scale_value", 1, "Value to scale the data with");
23
24 params.addParam<bool>("change_start_direction",
25 false,
26 "Whether or not to change the Ray's start point and direction");
27 params.addParam<bool>("change_direction_zero",
28 false,
29 "Whether or not to change the Ray's direction to the zero vector");
30 params.addParam<bool>(
31 "change_start_out_of_elem",
32 false,
33 "Whether or not to change the Ray's start point to a start out of the current element");
34
35 return params;
36}
37
39 : GeneralRayKernel(params),
40 _ray_data_index(isParamValid("data_name")
41 ? _study.getRayDataIndex(getParam<std::string>("data_name"))
42 : Ray::INVALID_RAY_DATA_INDEX),
43 _add_value(getParam<Real>("add_value")),
44 _scale_value(getParam<Real>("scale_value"))
45{
46 if (params.isParamSetByUser("add_value") && params.isParamSetByUser("scale_value"))
47 mooseError("Cannot add and scale value");
48}
49
50void
52{
54 {
57 }
58
59 if (getParam<bool>("change_start_direction"))
60 changeRayStartDirection(_current_elem->vertex_average(), -currentRay()->direction());
61 if (getParam<bool>("change_direction_zero"))
62 changeRayStartDirection(currentRay()->currentPoint(), Point(0, 0, 0));
63
64 if (getParam<bool>("change_start_out_of_elem"))
65 for (const auto neighbor : _current_elem->neighbor_ptr_range())
66 if (neighbor && neighbor != remote_elem)
67 {
68 changeRayStartDirection(neighbor->vertex_average(), currentRay()->direction());
69 break;
70 }
71}
registerMooseObject("RayTracingTestApp", ChangeRayRayKernelTest)
static InputParameters validParams()
ChangeRayRayKernelTest(const InputParameters &params)
virtual void onSegment() override
Called on each segment of a Ray.
const RayDataIndex _ray_data_index
static InputParameters validParams()
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
void changeRayStartDirection(const Point &start, const Point &direction)
Changes the current Ray's start point and direction.
const std::shared_ptr< Ray > & currentRay() const
Gets the current Ray that this is working on.
const Elem *const & _current_elem
The current Elem that _current_ray is tracing through.
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58
static const RayDataIndex INVALID_RAY_DATA_INDEX
Invalid index into a Ray's data.
Definition Ray.h:212