Line data Source code
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 : 12 : registerMooseObject("MooseApp", TimeDerivativeAux); 13 : 14 : InputParameters 15 14438 : TimeDerivativeAux::validParams() 16 : { 17 14438 : InputParameters params = AuxKernel::validParams(); 18 14438 : params.addClassDescription( 19 : "Returns the time derivative of the specified variable/functor as an auxiliary variable."); 20 : 21 14438 : params.addParam<MooseFunctorName>("functor", "Functor to take the time derivative of"); 22 14438 : params.addParam<MooseFunctorName>("factor", 1, "Factor to multiply the time derivative by"); 23 : 24 14438 : return params; 25 0 : } 26 : 27 88 : TimeDerivativeAux::TimeDerivativeAux(const InputParameters & parameters) 28 : : AuxKernel(parameters), 29 88 : _functor(getFunctor<Real>("functor")), 30 88 : _factor(getFunctor<Real>("factor")), 31 176 : _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var)) 32 : { 33 88 : const auto functor_name = getParam<MooseFunctorName>("functor"); 34 88 : if (_subproblem.hasVariable(functor_name)) 35 : { 36 48 : const auto * functor_var = &_subproblem.getVariable(_tid, functor_name); 37 74 : if (dynamic_cast<const MooseVariableFE<Real> *>(&_var) && 38 26 : !dynamic_cast<const MooseVariableFE<Real> *>(functor_var)) 39 4 : mooseWarning("'variable' argument is a finite element variable but 'functor' is not."); 40 66 : if (!dynamic_cast<const MooseVariableFE<Real> *>(&_var) && 41 22 : dynamic_cast<const MooseVariableFE<Real> *>(functor_var)) 42 4 : mooseWarning("'functor' argument is a finite element variable but 'variable' is not."); 43 : } 44 80 : if (isNodal()) 45 4 : paramError("variable", "This AuxKernel only supports Elemental fields"); 46 76 : } 47 : 48 : Real 49 10286 : TimeDerivativeAux::computeValue() 50 : { 51 10286 : if (_use_qp_arg) 52 : { 53 2726 : const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]}; 54 2726 : return _factor(qp_arg, determineState()) * _functor.dot(qp_arg, determineState()); 55 : } 56 : else 57 : { 58 7560 : const auto elem_arg = makeElemArg(_current_elem); 59 7560 : return _factor(elem_arg, determineState()) * _functor.dot(elem_arg, determineState()); 60 : } 61 : }