LCOV - code coverage report
Current view: top level - src/auxkernels - SecondTimeDerivativeAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 26 30 86.7 %
Date: 2025-08-08 20:01:16 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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 "SecondTimeDerivativeAux.h"
      11             : 
      12             : registerMooseObject("MooseApp", SecondTimeDerivativeAux);
      13             : 
      14             : InputParameters
      15       14309 : SecondTimeDerivativeAux::validParams()
      16             : {
      17       14309 :   InputParameters params = AuxKernel::validParams();
      18       14309 :   params.addClassDescription("Returns the second order time derivative of the specified variable "
      19             :                              "as an auxiliary variable.");
      20             : 
      21       14309 :   params.addRequiredCoupledVar("v", "Variable to take the second time derivative of");
      22       42927 :   params.addParam<MooseFunctorName>(
      23       28618 :       "factor", 1, "Factor to multiply the second time derivative by");
      24             : 
      25       14309 :   return params;
      26           0 : }
      27             : 
      28          27 : SecondTimeDerivativeAux::SecondTimeDerivativeAux(const InputParameters & parameters)
      29             :   : AuxKernel(parameters),
      30          27 :     _v(coupledDotDot("v")),
      31          27 :     _factor(getFunctor<Real>("factor")),
      32          54 :     _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var))
      33             : {
      34          27 :   const auto v_name = coupledName("v");
      35          27 :   if (_subproblem.hasVariable(v_name))
      36             :   {
      37          27 :     const auto * functor_var = &_subproblem.getVariable(_tid, v_name);
      38          50 :     if (dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
      39          23 :         !dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
      40           0 :       mooseWarning("'variable' argument is a finite element variable but 'v' is not.");
      41          31 :     if (!dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
      42           4 :         dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
      43           4 :       mooseWarning("'v' argument is a finite element variable but 'variable' is not.");
      44             :   }
      45          23 :   if (isNodal())
      46           4 :     paramError("variable", "This AuxKernel only supports Elemental fields");
      47          19 : }
      48             : 
      49             : Real
      50         456 : SecondTimeDerivativeAux::computeValue()
      51             : {
      52         456 :   if (_use_qp_arg)
      53             :   {
      54         456 :     const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
      55         456 :     return _factor(qp_arg, determineState()) * _v[_qp];
      56             :   }
      57             :   else
      58             :   {
      59           0 :     const auto elem_arg = makeElemArg(_current_elem);
      60           0 :     return _factor(elem_arg, determineState()) * _v[_qp];
      61             :   }
      62             : }

Generated by: LCOV version 1.14