https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TestTransientRaysStudy.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 "Function.h"
13
15
18{
19 auto params = RayTracingStudy::validParams();
20 params.addRequiredParam<FunctionName>("distance_function",
21 "The function to sample for the ray distances");
22 params.addRequiredParam<BoundaryName>("boundary", "The boundary to spawn rays from");
23 params.set<bool>("_use_ray_registration") = false;
24 return params;
25}
26
28 : RayTracingStudy(parameters),
29 _distance_function(getFunction("distance_function")),
30 _boundary_id(_mesh.getBoundaryID(getParam<BoundaryName>("boundary"))),
31 _generated_rays(declareRestartableData<bool>("generated_rays", false)),
32 _banked_rays(
33 declareRestartableDataWithContext<std::vector<std::shared_ptr<Ray>>>("banked_rays", this))
34{
35}
36
37void
39{
40 if (!_generated_rays)
41 {
42 for (const auto bnd_elem : *_mesh.getBoundaryElementRange())
43 if (bnd_elem->_elem->processor_id() == processor_id() && bnd_elem->_bnd_id == _boundary_id)
44 {
45 const auto elem = bnd_elem->_elem;
46 const auto side = elem->build_side_ptr(bnd_elem->_side);
47 const auto start_point = side->vertex_average();
48
49 auto ray = acquireRay();
50 ray->setStart(start_point, elem, bnd_elem->_side);
51 ray->setStartingDirection(elem->vertex_average() - start_point);
52 ray->setStartingMaxDistance(_distance_function.value(_fe_problem.time(), start_point));
53 moveRayToBuffer(ray);
54 }
55
56 _generated_rays = true;
57 }
58 else
59 {
60 for (auto & ray : _banked_rays)
61 {
62 const auto start_point = ray->currentPoint();
63 const auto direction = ray->direction();
64 const auto elem = ray->currentElem();
65
66 ray->resetCounters();
67 ray->clearStartingInfo();
68 ray->setStart(start_point, elem);
69 ray->setStartingDirection(direction);
70 ray->setStartingMaxDistance(_distance_function.value(_fe_problem.time(), start_point));
71 }
73 _banked_rays.clear();
74 }
75}
76
77void
registerMooseObject("RayTracingTestApp", TestTransientRaysStudy)
virtual Real & time() const
virtual Real value(Real t, const Point &p) const
libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > * getBoundaryElementRange()
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
static InputParameters validParams()
MooseMesh & _mesh
The Mesh.
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a ray to the buffer to be traced during generateRays().
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
const std::vector< std::shared_ptr< Ray > > & rayBank() const
Get the Ray bank.
void moveRaysToBuffer(std::vector< std::shared_ptr< Ray > > &rays)
Moves rays to the buffer to be traced during generateRays().
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58
TestTransientRaysStudy(const InputParameters &parameters)
static InputParameters validParams()
virtual void generateRays() override
Subclasses should override this to determine how to generate Rays.
std::vector< std::shared_ptr< Ray > > & _banked_rays
const Function & _distance_function
virtual void postExecuteStudy() override
Entry point after study execution.
FEProblemBase & _fe_problem
processor_id_type processor_id() const