Line data Source code
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 "FunctorCoordinatesFunctionAux.h"
11 : #include "Function.h"
12 :
13 : registerMooseObject("MooseApp", FunctorCoordinatesFunctionAux);
14 :
15 : InputParameters
16 14340 : FunctorCoordinatesFunctionAux::validParams()
17 : {
18 14340 : InputParameters params = AuxKernel::validParams();
19 14340 : params.addClassDescription(
20 : "Auxiliary Kernel that creates and updates a field variable by "
21 : "sampling a function with functors (variables, functions, others) as the coordinates.");
22 14340 : params.addRequiredParam<FunctionName>("function", "The function to use as the value");
23 14340 : params.addRequiredParam<MooseFunctorName>(
24 : "x_functor", "The functor to use for the X coordinate function argument");
25 14340 : params.addRequiredParam<MooseFunctorName>(
26 : "y_functor", "The functor to use for the Y coordinate function argument");
27 14340 : params.addRequiredParam<MooseFunctorName>(
28 : "z_functor", "The functor to use for the Z coordinate function argument");
29 14340 : params.addRequiredParam<MooseFunctorName>("t_functor",
30 : "The functor to use for the time function argument");
31 14340 : params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor");
32 :
33 14340 : return params;
34 0 : }
35 :
36 39 : FunctorCoordinatesFunctionAux::FunctorCoordinatesFunctionAux(const InputParameters & parameters)
37 : : AuxKernel(parameters),
38 39 : _func(getFunction("function")),
39 39 : _x_functor(getFunctor<Real>("x_functor")),
40 39 : _y_functor(getFunctor<Real>("y_functor")),
41 39 : _z_functor(getFunctor<Real>("z_functor")),
42 39 : _t_functor(getFunctor<Real>("t_functor")),
43 39 : _factor(getFunctor<Real>("factor")),
44 78 : _is_fe(dynamic_cast<MooseVariableFE<Real> *>(&_var))
45 : {
46 39 : if (!_is_fe && !dynamic_cast<MooseVariableFV<Real> *>(&_var) &&
47 0 : !dynamic_cast<MooseLinearVariableFV<Real> *>(&_var))
48 0 : paramError(
49 : "variable",
50 : "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
51 39 : }
52 :
53 : Real
54 4664 : FunctorCoordinatesFunctionAux::computeValue()
55 : {
56 4664 : const auto state = determineState();
57 4664 : if (isNodal())
58 : {
59 128 : const Moose::NodeArg node_arg = {_current_node,
60 128 : &Moose::NodeArg::undefined_subdomain_connection};
61 256 : return _factor(node_arg, state) * _func.value(_t_functor(node_arg, state),
62 128 : Point(_x_functor(node_arg, state),
63 128 : _y_functor(node_arg, state),
64 256 : _z_functor(node_arg, state)));
65 : }
66 4536 : else if (_is_fe)
67 : {
68 3888 : const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
69 7776 : return _factor(qp_arg, state) * _func.value(_t_functor(qp_arg, state),
70 3888 : Point(_x_functor(qp_arg, state),
71 3888 : _y_functor(qp_arg, state),
72 7776 : _z_functor(qp_arg, state)));
73 : }
74 : else
75 : {
76 648 : const auto elem_arg = makeElemArg(_current_elem);
77 1296 : return _factor(elem_arg, state) * _func.value(_t_functor(elem_arg, state),
78 648 : Point(_x_functor(elem_arg, state),
79 648 : _y_functor(elem_arg, state),
80 1296 : _z_functor(elem_arg, state)));
81 : }
82 : }
|