LCOV - code coverage report
Current view: top level - src/kernels - ArrayTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 35 44 79.5 %
Date: 2025-07-17 01:28:37 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       14699 : ArrayTimeDerivative::validParams()
      16             : {
      17       14699 :   InputParameters params = ArrayTimeKernel::validParams();
      18       14699 :   params.addClassDescription("Array time derivative operator with the weak form of $(\\psi_i, "
      19             :                              "\\frac{\\partial u_h}{\\partial t})$.");
      20       14699 :   params.addParam<MaterialPropertyName>("time_derivative_coefficient",
      21             :                                         "The name of the time derivative coefficient. "
      22             :                                         "Can be scalar, vector, or matrix material property.");
      23       14699 :   return params;
      24           0 : }
      25             : 
      26         222 : ArrayTimeDerivative::ArrayTimeDerivative(const InputParameters & parameters)
      27             :   : ArrayTimeKernel(parameters),
      28         222 :     _has_coefficient(isParamValid("time_derivative_coefficient")),
      29         313 :     _coeff(_has_coefficient && hasMaterialProperty<Real>("time_derivative_coefficient")
      30         313 :                ? &getMaterialProperty<Real>("time_derivative_coefficient")
      31             :                : nullptr),
      32         626 :     _coeff_array(_has_coefficient &&
      33         313 :                          hasMaterialProperty<RealEigenVector>("time_derivative_coefficient")
      34         313 :                      ? &getMaterialProperty<RealEigenVector>("time_derivative_coefficient")
      35             :                      : nullptr),
      36         626 :     _coeff_2d_array(_has_coefficient &&
      37         313 :                             hasMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
      38         313 :                         ? &getMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
      39         222 :                         : nullptr)
      40             : {
      41         222 :   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         222 : }
      47             : 
      48             : void
      49    37730384 : ArrayTimeDerivative::computeQpResidual(RealEigenVector & residual)
      50             : {
      51    37730384 :   if (!_has_coefficient)
      52    24104544 :     residual = _u_dot[_qp] * _test[_i][_qp];
      53    13625840 :   else if (_coeff)
      54           0 :     residual = (*_coeff)[_qp] * _u_dot[_qp] * _test[_i][_qp];
      55    13625840 :   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    13625840 :     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    37730384 : }
      75             : 
      76             : RealEigenVector
      77    22416368 : ArrayTimeDerivative::computeQpJacobian()
      78             : {
      79    22416368 :   Real tmp = _test[_i][_qp] * _phi[_j][_qp] * _du_dot_du[_qp];
      80    22416368 :   if (!_has_coefficient)
      81    26879456 :     return RealEigenVector::Constant(_var.count(), tmp);
      82     8976640 :   else if (_coeff)
      83           0 :     return RealEigenVector::Constant(_var.count(), tmp * (*_coeff)[_qp]);
      84     8976640 :   else if (_coeff_array)
      85    17953280 :     return tmp * (*_coeff_array)[_qp];
      86             :   else
      87           0 :     return tmp * (*_coeff_2d_array)[_qp].diagonal();
      88             : }
      89             : 
      90             : RealEigenMatrix
      91    14210528 : ArrayTimeDerivative::computeQpOffDiagJacobian(const MooseVariableFEBase & jvar)
      92             : {
      93    14210528 :   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    14210528 :     return ArrayKernel::computeQpOffDiagJacobian(jvar);
      97             : }

Generated by: LCOV version 1.14