https://mooseframework.inl.gov
FunctorAux.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 "FunctorAux.h"
11 
12 registerMooseObject("MooseApp", FunctorAux);
13 registerMooseObjectRenamed("MooseApp", FunctorElementalAux, "10/14/2024 00:00", FunctorAux);
14 registerMooseObjectRenamed("MooseApp", ADFunctorElementalAux, "10/14/2024 00:00", FunctorAux);
15 
18 {
20  params.addClassDescription(
21  "Evaluates a functor (variable, function or functor material property) on the current "
22  "element, quadrature point, or node.");
23  params.addRequiredParam<MooseFunctorName>("functor", "The functor to evaluate");
24  params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor");
25  return params;
26 }
27 
29  : AuxKernel(parameters),
30  _functor(getFunctor<Real>("functor")),
31  _factor(getFunctor<Real>("factor")),
32  _is_standard_fe(dynamic_cast<MooseVariableFE<Real> *>(&_var)),
33  _is_standard_fv(dynamic_cast<MooseVariableFV<Real> *>(&_var) ||
34  dynamic_cast<MooseLinearVariableFV<Real> *>(&_var))
35 {
37  paramError(
38  "variable",
39  "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
40 
41  const auto & functor_name = getParam<MooseFunctorName>("functor");
42 
43  // Add user object to dependency
44  if (hasUserObjectByName(functor_name))
45  getUserObjectBaseByName(functor_name);
46 }
47 
48 Real
50 {
51  const auto state = determineState();
52  if (isNodal())
53  {
54  const Moose::NodeArg node_arg = {_current_node,
56  return _factor(node_arg, state) * _functor(node_arg, state);
57  }
58  else if (_is_standard_fe)
59  {
60  const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
61  return _factor(qp_arg, state) * _functor(qp_arg, state);
62  }
63  else
64  {
65  const auto elem_arg = makeElemArg(_current_elem);
66  return _factor(elem_arg, state) * _functor(elem_arg, state);
67  }
68 }
const bool _is_standard_fv
Whether the variable is a standard finite volume variable.
Definition: FunctorAux.h:38
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:33
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:467
registerMooseObject("MooseApp", FunctorAux)
Evaluate a functor (functor material property, function or variable) with either a cell-center...
Definition: FunctorAux.h:18
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:138
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...
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...
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...
registerMooseObjectRenamed("MooseApp", FunctorElementalAux, "10/14/2024 00:00", FunctorAux)
const UserObjectBase & getUserObjectBaseByName(const UserObjectName &object_name, bool is_dependency=true) const
Get an user object with the name object_name.
Argument for requesting functor evaluation at a quadrature point location in an element.
static InputParameters validParams()
Definition: FunctorAux.C:17
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:122
const Moose::Functor< Real > & _functor
Functor to evaluate with the element argument.
Definition: FunctorAux.h:29
const Moose::Functor< Real > & _factor
Factor to multiply the functor with.
Definition: FunctorAux.h:32
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:128
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:150
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...
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: FunctorAux.C:49
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
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:17
This class provides variable solution values for other classes/objects to bind to when looping over f...
FunctorAux(const InputParameters &parameters)
Definition: FunctorAux.C:28
const MooseArray< Point > & _q_point
Active quadrature points.
Definition: AuxKernel.h:120
This class provides variable solution interface for linear finite volume problems.
Definition: FVUtils.h:24
const bool _is_standard_fe
Whether the variable is a standard finite element variable.
Definition: FunctorAux.h:35
bool hasUserObjectByName(const UserObjectName &object_name) const
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:43