https://mooseframework.inl.gov
StationaryRayStudyTest.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 "StationaryRayStudyTest.h"
11 
12 #include "Function.h"
13 
14 registerMooseObject("RayTracingTestApp", StationaryRayStudyTest);
15 
18 {
19  auto params = RayTracingStudy::validParams();
20 
21  params.addParam<std::vector<FunctionName>>(
22  "data_functions", {}, "Functions to use to set the data (if any)");
23  params.addParam<std::vector<FunctionName>>(
24  "aux_data_functions", {}, "Functions to use to set the aux data (if any)");
25 
26  params.set<bool>("_use_ray_registration") = false;
27 
28  return params;
29 }
30 
32  : RayTracingStudy(parameters)
33 {
34  for (const auto & function : getParam<std::vector<FunctionName>>("data_functions"))
35  _data_functions.emplace_back(registerRayData(function), &getFunctionByName(function));
36 
37  for (const auto & function : getParam<std::vector<FunctionName>>("aux_data_functions"))
38  _aux_data_functions.emplace_back(registerRayAuxData(function), &getFunctionByName(function));
39 }
40 
41 void
43 {
44  const auto define_ray = [this](const auto elem, const auto & start)
45  {
46  auto ray = acquireRay();
47  ray->setStart(start, elem);
48  ray->setStationary();
49  for (const auto & [i, function] : _data_functions)
50  ray->data(i) = function->value(_t, start);
51  for (const auto & [i, function] : _aux_data_functions)
52  ray->auxData(i) = function->value(_t, start);
53  moveRayToBuffer(ray);
54  };
55 
56  // elem centroids
57  for (const Elem * elem : *_mesh.getActiveLocalElementRange())
58  define_ray(elem, elem->vertex_average());
59  // boundary side centroids
60  for (const auto & bnd_elem : *_mesh.getBoundaryElementRange())
61  {
62  const Elem * elem = bnd_elem->_elem;
63  if (elem->processor_id() == _pid)
64  define_ray(elem, elemSide(*elem, bnd_elem->_side).vertex_average());
65  }
66 }
RayDataIndex registerRayData(const std::string &name)
Register a value to be filled in the data on a Ray with a given name.
libMesh::ConstElemRange * getActiveLocalElementRange()
RayDataIndex registerRayAuxData(const std::string &name)
Register a value to be filled in the aux data on a Ray with a given name.
MooseMesh & _mesh
The Mesh.
std::shared_ptr< Ray > acquireRay()
User APIs for constructing Rays within the RayTracingStudy.
virtual void generateRays() override
Subclasses should override this to determine how to generate Rays.
std::vector< std::pair< RayDataIndex, const Function * > > _data_functions
const T & getParam(const std::string &name) const
static InputParameters validParams()
static InputParameters validParams()
StationaryRayStudyTest(const InputParameters &parameters)
registerMooseObject("RayTracingTestApp", StationaryRayStudyTest)
const Function & getFunctionByName(const FunctionName &name) const
const libMesh::Elem & elemSide(const libMesh::Elem &elem, const unsigned int s, const THREAD_ID tid=0)
Get an element&#39;s side pointer without excessive memory allocation.
std::vector< std::pair< RayDataIndex, const Function * > > _aux_data_functions
const processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once) ...
void moveRayToBuffer(std::shared_ptr< Ray > &ray)
Moves a ray to the buffer to be traced during generateRays().
libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement *> * getBoundaryElementRange()
Point vertex_average() const
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...