https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TimeDerivativeAux.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 "TimeDerivativeAux.h"
11
13
16{
19 "Returns the time derivative of the specified variable/functor as an auxiliary variable.");
20
21 params.addParam<MooseFunctorName>("functor", "Functor to take the time derivative of");
22 params.addParam<MooseFunctorName>("factor", 1, "Factor to multiply the time derivative by");
23
24 return params;
25}
26
28 : AuxKernel(parameters),
29 _functor(getFunctor<Real>("functor")),
30 _factor(getFunctor<Real>("factor")),
31 _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var))
32{
33 const auto functor_name = getParam<MooseFunctorName>("functor");
34 if (_subproblem.hasVariable(functor_name))
35 {
36 const auto * functor_var = &_subproblem.getVariable(_tid, functor_name);
37 if (dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
38 !dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
39 mooseWarning("'variable' argument is a finite element variable but 'functor' is not.");
40 if (!dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
41 dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
42 mooseWarning("'functor' argument is a finite element variable but 'variable' is not.");
43 }
44 if (isNodal())
45 paramError("variable", "This AuxKernel only supports Elemental fields");
46}
47
48Real
50{
51 if (_use_qp_arg)
52 {
54 return _factor(qp_arg, determineState()) * _functor.dot(qp_arg, determineState());
55 }
56 else
57 {
58 const auto elem_arg = makeElemArg(_current_elem);
59 return _factor(elem_arg, determineState()) * _functor.dot(elem_arg, determineState());
60 }
61}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
registerMooseObject("MooseApp", TimeDerivativeAux)
SubProblem & _subproblem
Subproblem this kernel is part of.
const THREAD_ID _tid
Thread ID.
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
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
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 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
Class for stuff related to variables.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
Time derivative of a functor, which can be a variable, function, functor material property.
virtual Real computeValue() override
Compute and return the value of the aux variable.
const Moose::Functor< Real > & _factor
Factor to multiply the time derivative with.
const bool _use_qp_arg
Whether to use a quadrature-based functor argument, appropriate for finite element evaluations.
const Moose::Functor< Real > & _functor
Functor to take the time derivative of.
static InputParameters validParams()
TimeDerivativeAux(const InputParameters &parameters)
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.