https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
32void
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
63void
registerMooseObject("RayTracingTestApp", TestReuseRaysStudy)
void mooseError(Args &&... args) const
virtual unsigned int dimension() const
const libMesh::ConstElemRange * getActiveLocalElementRange()
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
Tests the re-use of banked rays.
static InputParameters validParams()
TestReuseRaysStudy(const InputParameters &parameters)
virtual void postExecuteStudy() override
Entry point after study execution.
virtual void generateRays() override
Subclasses should override this to determine how to generate Rays.
std::vector< std::shared_ptr< Ray > > & _banked_rays