https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
13registerMooseObjectRenamed("MooseApp", FunctorElementalAux, "10/14/2024 00:00", FunctorAux);
14registerMooseObjectRenamed("MooseApp", ADFunctorElementalAux, "10/14/2024 00:00", FunctorAux);
15
18{
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{
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
48Real
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 {
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}
registerMooseObjectRenamed("MooseApp", FunctorElementalAux, "10/14/2024 00:00", FunctorAux)
registerMooseObject("MooseApp", FunctorAux)
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
const QBase *const & _qrule
Quadrature rule being used.
Definition AuxKernel.h:127
static InputParameters validParams()
Definition AuxKernel.C:27
Evaluate a functor (functor material property, function or variable) with either a cell-center,...
Definition FunctorAux.h:19
static InputParameters validParams()
Definition FunctorAux.C:17
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition FunctorAux.C:49
FunctorAux(const InputParameters &parameters)
Definition FunctorAux.C:28
const bool _is_standard_fe
Whether the variable is a standard finite element variable.
Definition FunctorAux.h:35
const bool _is_standard_fv
Whether the variable is a standard finite volume variable.
Definition FunctorAux.h:38
const Moose::Functor< Real > & _factor
Factor to multiply the functor with.
Definition FunctorAux.h:32
const Moose::Functor< Real > & _functor
Functor to evaluate with the element argument.
Definition FunctorAux.h:29
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.
bool hasUserObjectByName(const UserObjectName &object_name) const
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 const std::set< SubdomainID > undefined_subdomain_connection
A static member that can be used when the connection of a node to subdomains is unknown.