https://mooseframework.inl.gov
TestReuseRaysStudy.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 "TestReuseRaysStudy.h"
11 
12 registerMooseObject("RayTracingTestApp", TestReuseRaysStudy);
13 
16 {
17  auto params = RayTracingStudy::validParams();
18  params.set<bool>("_use_ray_registration") = false;
19  return params;
20 }
21 
23  : RayTracingStudy(parameters),
24  _executed_once(declareRestartableData<bool>("executed_once", false)),
25  _banked_rays(
26  declareRestartableDataWithContext<std::vector<std::shared_ptr<Ray>>>("banked_rays", this))
27 {
28  if (_mesh.dimension() != 1)
29  mooseError("Works with 1D only");
30 }
31 
32 void
34 {
35  if (!_executed_once)
36  for (const auto elem : *_mesh.getActiveLocalElementRange())
37  {
38  auto ray = acquireRay();
39  ray->setStart(elem->vertex_average(), elem);
40  ray->setStartingDirection(Point(1, 0, 0));
41  moveRayToBuffer(ray);
42  }
43  else
44  {
45  for (std::shared_ptr<Ray> & ray : _banked_rays)
46  {
47  const auto start_point = ray->currentPoint();
48  const auto direction = ray->direction();
49  const auto elem = ray->currentElem();
50 
51  ray->resetCounters();
52  ray->clearStartingInfo();
53  ray->setStart(start_point, elem);
54  ray->setStartingDirection(-direction);
55  }
57  _banked_rays.clear();
58  }
59 
60  _executed_once = true;
61 }
62 
63 void
65 {
67 }
libMesh::ConstElemRange * getActiveLocalElementRange()
const std::vector< std::shared_ptr< Ray > > & rayBank() const
Get the Ray bank.
MooseMesh & _mesh
The Mesh.
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
virtual void postExecuteStudy() override
Entry point after study execution.
virtual void generateRays() override
Subclasses should override this to determine how to generate Rays.
static InputParameters validParams()
virtual unsigned int dimension() const
static InputParameters validParams()
registerMooseObject("RayTracingTestApp", TestReuseRaysStudy)
Basic datastructure for a ray that will traverse the mesh.
Definition: Ray.h:56
std::vector< std::shared_ptr< Ray > > & _banked_rays
void mooseError(Args &&... args) const
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a ray to the buffer to be traced during generateRays().
void moveRaysToBuffer(std::vector< std::shared_ptr< Ray >> &rays)
Moves rays to the buffer to be traced during generateRays().
TestReuseRaysStudy(const InputParameters &parameters)
Tests the re-use of banked rays.
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...