https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11
12#include "Function.h"
13
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
41void
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}
registerMooseObject("RayTracingTestApp", StationaryRayStudyTest)
const Function & getFunctionByName(const FunctionName &name) const
const libMesh::ConstElemRange * getActiveLocalElementRange()
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...
RayDataIndex registerRayAuxData(const std::string &name)
Register a value to be filled in the aux data on a Ray with a given name.
RayDataIndex registerRayData(const std::string &name)
Register a value to be filled in the data on a Ray with a given name.
const libMesh::Elem & elemSide(const libMesh::Elem &elem, const unsigned int s, const THREAD_ID tid=0)
Get an element's side pointer without excessive memory allocation.
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 processor_id_type _pid
The rank of this processor (this actually takes time to lookup - so just do it once)
std::vector< std::pair< RayDataIndex, const Function * > > _aux_data_functions
StationaryRayStudyTest(const InputParameters &parameters)
virtual void generateRays() override
Subclasses should override this to determine how to generate Rays.
static InputParameters validParams()
std::vector< std::pair< RayDataIndex, const Function * > > _data_functions
Point vertex_average() const