https://mooseframework.inl.gov
FunctorKernel.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 "FunctorKernel.h"
11 
13 
16 {
18 
19  params.addClassDescription("Adds a term from a functor.");
20 
21  params.addRequiredParam<MooseFunctorName>("functor", "Functor to add");
22  params.addRequiredParam<bool>(
23  "functor_on_rhs",
24  "If true, the functor to add is on the right hand side of the equation. By convention, all "
25  "terms are moved to the left hand side, so if true, a factor of -1 is applied.");
26 
27  return params;
28 }
29 
31  : ADKernelValue(parameters),
32  _functor(getFunctor<ADReal>("functor")),
33  _sign(getParam<bool>("functor_on_rhs") ? -1.0 : 1.0)
34 {
35 }
36 
37 ADReal
39 {
40  const Moose::ElemQpArg space_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
41  return _sign * _functor(space_arg, Moose::currentState());
42 }
virtual ADReal precomputeQpResidual() override
Called before forming the residual for an element.
Definition: FunctorKernel.C:38
static InputParameters validParams()
Definition: ADKernelValue.C:20
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
FunctorKernel(const InputParameters &parameters)
Definition: FunctorKernel.C:30
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
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...
const Real _sign
Sign to apply to functor.
Definition: FunctorKernel.h:30
registerMooseObject("MooseApp", FunctorKernel)
const QBase *const & _qrule
active quadrature rule
Definition: KernelBase.h:49
Argument for requesting functor evaluation at a quadrature point location in an element.
const Moose::Functor< ADReal > & _functor
Functor to add.
Definition: FunctorKernel.h:28
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...
static InputParameters validParams()
Definition: FunctorKernel.C:15
const Elem *const & _current_elem
Current element.
Definition: KernelBase.h:37
StateArg currentState()
const MooseArray< Point > & _q_point
The physical location of the element&#39;s quadrature Points, indexed by _qp.
Definition: KernelBase.h:46
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43
Adds a term from a functor.
Definition: FunctorKernel.h:17