LCOV - code coverage report
Current view: top level - src/kernels - ArrayTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 35 44 79.5 %
Date: 2025-08-08 20:01:16 Functions: 5 5 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 "ArrayTimeDerivative.h"
      11             : 
      12             : registerMooseObject("MooseApp", ArrayTimeDerivative);
      13             : 
      14             : InputParameters
      15       14723 : ArrayTimeDerivative::validParams()
      16             : {
      17       14723 :   InputParameters params = ArrayTimeKernel::validParams();
      18       14723 :   params.addClassDescription("Array time derivative operator with the weak form of $(\\psi_i, "
      19             :                              "\\frac{\\partial u_h}{\\partial t})$.");
      20       14723 :   params.addParam<MaterialPropertyName>("time_derivative_coefficient",
      21             :                                         "The name of the time derivative coefficient. "
      22             :                                         "Can be scalar, vector, or matrix material property.");
      23       14723 :   return params;
      24           0 : }
      25             : 
      26         234 : ArrayTimeDerivative::ArrayTimeDerivative(const InputParameters & parameters)
      27             :   : ArrayTimeKernel(parameters),
      28         234 :     _has_coefficient(isParamValid("time_derivative_coefficient")),
      29         332 :     _coeff(_has_coefficient && hasMaterialProperty<Real>("time_derivative_coefficient")
      30         332 :                ? &getMaterialProperty<Real>("time_derivative_coefficient")
      31             :                : nullptr),
      32         664 :     _coeff_array(_has_coefficient &&
      33         332 :                          hasMaterialProperty<RealEigenVector>("time_derivative_coefficient")
      34         332 :                      ? &getMaterialProperty<RealEigenVector>("time_derivative_coefficient")
      35             :                      : nullptr),
      36         664 :     _coeff_2d_array(_has_coefficient &&
      37         332 :                             hasMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
      38         332 :                         ? &getMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
      39         234 :                         : nullptr)
      40             : {
      41         234 :   if (!_coeff && !_coeff_array && !_coeff_2d_array && _has_coefficient)
      42             :   {
      43           0 :     MaterialPropertyName mat = getParam<MaterialPropertyName>("time_derivative_coefficient");
      44           0 :     mooseError("Property " + mat + " is of unsupported type for ArrayTimeDerivative");
      45           0 :   }
      46         234 : }
      47             : 
      48             : void
      49    40497496 : ArrayTimeDerivative::computeQpResidual(RealEigenVector & residual)
      50             : {
      51    40497496 :   if (!_has_coefficient)
      52    24827808 :     residual = _u_dot[_qp] * _test[_i][_qp];
      53    15669688 :   else if (_coeff)
      54           0 :     residual = (*_coeff)[_qp] * _u_dot[_qp] * _test[_i][_qp];
      55    15669688 :   else if (_coeff_array)
      56             :   {
      57             :     mooseAssert((*_coeff_array)[_qp].size() == _var.count(),
      58             :                 "time_derivative_coefficient size is inconsistent with the number of components "
      59             :                 "in array variable");
      60             :     // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
      61    15669688 :     residual.noalias() = (*_coeff_array)[_qp].asDiagonal() * _u_dot[_qp] * _test[_i][_qp];
      62             :   }
      63             :   else
      64             :   {
      65             :     mooseAssert((*_coeff_2d_array)[_qp].cols() == _var.count(),
      66             :                 "time_derivative_coefficient size is inconsistent with the number of components "
      67             :                 "in array variable");
      68             :     mooseAssert((*_coeff_2d_array)[_qp].rows() == _var.count(),
      69             :                 "time_derivative_coefficient size is inconsistent with the number of components "
      70             :                 "in array variable");
      71             :     // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
      72           0 :     residual.noalias() = (*_coeff_2d_array)[_qp] * _u_dot[_qp] * _test[_i][_qp];
      73             :   }
      74    40497496 : }
      75             : 
      76             : RealEigenVector
      77    25738080 : ArrayTimeDerivative::computeQpJacobian()
      78             : {
      79    25738080 :   Real tmp = _test[_i][_qp] * _phi[_j][_qp] * _du_dot_du[_qp];
      80    25738080 :   if (!_has_coefficient)
      81    30736224 :     return RealEigenVector::Constant(_var.count(), tmp);
      82    10369968 :   else if (_coeff)
      83           0 :     return RealEigenVector::Constant(_var.count(), tmp * (*_coeff)[_qp]);
      84    10369968 :   else if (_coeff_array)
      85    20739936 :     return tmp * (*_coeff_array)[_qp];
      86             :   else
      87           0 :     return tmp * (*_coeff_2d_array)[_qp].diagonal();
      88             : }
      89             : 
      90             : RealEigenMatrix
      91    16161632 : ArrayTimeDerivative::computeQpOffDiagJacobian(const MooseVariableFEBase & jvar)
      92             : {
      93    16161632 :   if (jvar.number() == _var.number() && _coeff_2d_array)
      94           0 :     return _phi[_j][_qp] * _test[_i][_qp] * _du_dot_du[_qp] * (*_coeff_2d_array)[_qp];
      95             :   else
      96    16161632 :     return ArrayKernel::computeQpOffDiagJacobian(jvar);
      97             : }

Generated by: LCOV version 1.14