LCOV - code coverage report
Current view: top level - src/auxkernels - SecondTimeDerivativeAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 26 30 86.7 %
Date: 2025-07-17 01:28:37 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       14307 : SecondTimeDerivativeAux::validParams()
      16             : {
      17       14307 :   InputParameters params = AuxKernel::validParams();
      18       14307 :   params.addClassDescription("Returns the second order time derivative of the specified variable "
      19             :                              "as an auxiliary variable.");
      20             : 
      21       14307 :   params.addRequiredCoupledVar("v", "Variable to take the second time derivative of");
      22       42921 :   params.addParam<MooseFunctorName>(
      23       28614 :       "factor", 1, "Factor to multiply the second time derivative by");
      24             : 
      25       14307 :   return params;
      26           0 : }
      27             : 
      28          26 : SecondTimeDerivativeAux::SecondTimeDerivativeAux(const InputParameters & parameters)
      29             :   : AuxKernel(parameters),
      30          26 :     _v(coupledDotDot("v")),
      31          26 :     _factor(getFunctor<Real>("factor")),
      32          52 :     _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var))
      33             : {
      34          26 :   const auto v_name = coupledName("v");
      35          26 :   if (_subproblem.hasVariable(v_name))
      36             :   {
      37          26 :     const auto * functor_var = &_subproblem.getVariable(_tid, v_name);
      38          48 :     if (dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
      39          22 :         !dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
      40           0 :       mooseWarning("'variable' argument is a finite element variable but 'v' is not.");
      41          30 :     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          22 :   if (isNodal())
      46           4 :     paramError("variable", "This AuxKernel only supports Elemental fields");
      47          18 : }
      48             : 
      49             : Real
      50         384 : SecondTimeDerivativeAux::computeValue()
      51             : {
      52         384 :   if (_use_qp_arg)
      53             :   {
      54         384 :     const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
      55         384 :     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