https://mooseframework.inl.gov
LineSourceRayKernel.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 "LineSourceRayKernel.h"
11 
12 // MOOSE includes
13 #include "Function.h"
14 
17 
18 template <bool is_ad>
21 {
23 
24  params.addClassDescription(
25  "Demonstrates the multiple ways that scalar values can be introduced "
26  "into RayKernels, e.g. (controllable) constants, functions, "
27  "postprocessors, and data on rays. Implements the weak form $(\\psi_i, -f)$ along a line.");
28 
29  params.addParam<Real>("value", 1.0, "Coefficient to multiply by the line source term");
30  params.addParam<FunctionName>("function", "1", "A function that describes the line source");
31  params.addParam<PostprocessorName>(
32  "postprocessor", 1, "A postprocessor whose value is multiplied by the line source");
33  params.addParam<std::vector<std::string>>(
34  "ray_data_factor_names", {}, "The names of the Ray data to scale the source by (if any)");
35  params.addParam<std::vector<std::string>>(
36  "ray_aux_data_factor_names",
37  {},
38  "The names of the Ray aux data to scale the source by (if any)");
39 
40  params.declareControllable("value");
41 
42  return params;
43 }
44 
45 template <bool is_ad>
47  : GenericRayKernel<is_ad>(params),
48  _scale(this->template getParam<Real>("value")),
49  _function(getFunction("function")),
50  _postprocessor(getPostprocessorValue("postprocessor")),
51  _ray_data_factor_indices(this->_study.getRayDataIndices(
52  this->template getParam<std::vector<std::string>>("ray_data_factor_names"))),
53  _ray_aux_data_factor_indices(this->_study.getRayAuxDataIndices(
54  this->template getParam<std::vector<std::string>>("ray_aux_data_factor_names")))
55 {
56 }
57 
58 template <bool is_ad>
61 {
62  Real factor = _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
63 
64  // Scale by any Ray data and aux data if given
65  for (const auto index : _ray_data_factor_indices)
66  factor *= currentRay()->data(index);
67  for (const auto index : _ray_aux_data_factor_indices)
68  factor *= currentRay()->auxData(index);
69 
70  return _test[_i][_qp] * -factor;
71 }
72 
73 template class LineSourceRayKernelTempl<false>;
74 template class LineSourceRayKernelTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
static InputParameters validParams()
LineSourceRayKernelTempl(const InputParameters &params)
virtual GenericReal< is_ad > computeQpResidual() override
Compute this RayKernel&#39;s contribution to the residual at _qp and _i.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
registerMooseObject("RayTracingApp", LineSourceRayKernel)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})