https://mooseframework.inl.gov
FunctorCoordinatesFunctionAux.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 #include "Function.h"
12 
14 
17 {
19  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  params.addRequiredParam<FunctionName>("function", "The function to use as the value");
23  params.addRequiredParam<MooseFunctorName>(
24  "x_functor", "The functor to use for the X coordinate function argument");
25  params.addRequiredParam<MooseFunctorName>(
26  "y_functor", "The functor to use for the Y coordinate function argument");
27  params.addRequiredParam<MooseFunctorName>(
28  "z_functor", "The functor to use for the Z coordinate function argument");
29  params.addRequiredParam<MooseFunctorName>("t_functor",
30  "The functor to use for the time function argument");
31  params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor");
32 
33  return params;
34 }
35 
37  : AuxKernel(parameters),
38  _func(getFunction("function")),
39  _x_functor(getFunctor<Real>("x_functor")),
40  _y_functor(getFunctor<Real>("y_functor")),
41  _z_functor(getFunctor<Real>("z_functor")),
42  _t_functor(getFunctor<Real>("t_functor")),
43  _factor(getFunctor<Real>("factor")),
44  _is_fe(dynamic_cast<MooseVariableFE<Real> *>(&_var))
45 {
46  if (!_is_fe && !dynamic_cast<MooseVariableFV<Real> *>(&_var) &&
47  !dynamic_cast<MooseLinearVariableFV<Real> *>(&_var))
48  paramError(
49  "variable",
50  "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
51 }
52 
53 Real
55 {
56  const auto state = determineState();
57  if (isNodal())
58  {
59  const Moose::NodeArg node_arg = {_current_node,
61  return _factor(node_arg, state) * _func.value(_t_functor(node_arg, state),
62  Point(_x_functor(node_arg, state),
63  _y_functor(node_arg, state),
64  _z_functor(node_arg, state)));
65  }
66  else if (_is_fe)
67  {
68  const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
69  return _factor(qp_arg, state) * _func.value(_t_functor(qp_arg, state),
70  Point(_x_functor(qp_arg, state),
71  _y_functor(qp_arg, state),
72  _z_functor(qp_arg, state)));
73  }
74  else
75  {
76  const auto elem_arg = makeElemArg(_current_elem);
77  return _factor(elem_arg, state) * _func.value(_t_functor(elem_arg, state),
78  Point(_x_functor(elem_arg, state),
79  _y_functor(elem_arg, state),
80  _z_functor(elem_arg, state)));
81  }
82 }
const Function & _func
Function being used to compute the value of this kernel.
static const std::set< SubdomainID > undefined_subdomain_connection
A static member that can be used when the connection of a node to subdomains is unknown.
Class for stuff related to variables.
Definition: Adaptivity.h:31
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:214
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Moose::Functor< Real > & _t_functor
Functor being used to provide the &#39;t&#39; coordinate.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual Real computeValue() override
Compute and return the value of the aux variable.
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Helper method to create an elemental argument for a functor that includes whether to perform skewness...
const Moose::Functor< Real > & _y_functor
Functor being used to provide the &#39;y&#39; coordinate.
const Moose::Functor< Real > & _z_functor
Functor being used to provide the &#39;z&#39; coordinate.
registerMooseObject("MooseApp", FunctorCoordinatesFunctionAux)
Argument for requesting functor evaluation at a quadrature point location in an element.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const Moose::Functor< Real > & _x_functor
Functor being used to provide the &#39;x&#39; coordinate.
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:198
const bool _is_fe
Whether the target variable is finite element.
FunctorCoordinatesFunctionAux(const InputParameters &parameters)
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:44
const MooseArray< Point > & _q_point
Active quadrature points.
Definition: AuxKernel.h:196
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:86
const Moose::Functor< Real > & _factor
A factor to multiply the output value with for convenience.