https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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))
49 "variable",
50 "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
51}
52
53Real
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 {
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}
registerMooseObject("MooseApp", FunctorCoordinatesFunctionAux)
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const MooseArray< Point > & _q_point
Active quadrature points.
Definition AuxKernel.h:125
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition AuxKernel.h:143
unsigned int _qp
Quadrature point index.
Definition AuxKernel.h:155
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable, hides base _var.
Definition AuxKernel.h:113
const QBase *const & _qrule
Quadrature rule being used.
Definition AuxKernel.h:127
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:30
const Moose::Functor< Real > & _factor
A factor to multiply the output value with for convenience.
const Function & _func
Function being used to compute the value of this kernel.
virtual Real computeValue() override
Compute and return the value of the aux variable.
const Moose::Functor< Real > & _t_functor
Functor being used to provide the 't' coordinate.
const Moose::Functor< Real > & _x_functor
Functor being used to provide the 'x' coordinate.
const Moose::Functor< Real > & _z_functor
Functor being used to provide the 'z' coordinate.
FunctorCoordinatesFunctionAux(const InputParameters &parameters)
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const bool _is_fe
Whether the target variable is finite element.
const Moose::Functor< Real > & _y_functor
Functor being used to provide the 'y' coordinate.
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...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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 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 ...
Definition MooseBase.h:457
This class provides variable solution interface for linear finite volume problems.
Class for stuff related to variables.
This class provides variable solution values for other classes/objects to bind to when looping over f...
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
Argument for requesting functor evaluation at a quadrature point location in an element.
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.