LCOV - code coverage report
Current view: top level - src/kernels - SusceptibilityTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 28 29 96.6 %
Date: 2025-09-04 07:55:36 Functions: 10 10 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 "SusceptibilityTimeDerivative.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", SusceptibilityTimeDerivative);
      13             : registerMooseObject("PhaseFieldApp", ADSusceptibilityTimeDerivative);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17         261 : SusceptibilityTimeDerivativeTempl<is_ad>::validParams()
      18             : {
      19         261 :   InputParameters params = SusceptibilityTimeDerivativeBase<is_ad>::validParams();
      20         261 :   params.addClassDescription(
      21             :       "A modified time derivative Kernel that multiplies the time derivative "
      22             :       "of a variable by a generalized susceptibility");
      23         522 :   params.addRequiredParam<MaterialPropertyName>(
      24             :       "f_name", "Susceptibility function F defined in a FunctionMaterial");
      25         522 :   params.addCoupledVar("args", "Vector of variable arguments of the susceptibility");
      26         522 :   params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
      27         261 :   return params;
      28           0 : }
      29             : 
      30             : template <bool is_ad>
      31         137 : SusceptibilityTimeDerivativeTempl<is_ad>::SusceptibilityTimeDerivativeTempl(
      32             :     const InputParameters & parameters)
      33             :   : DerivativeMaterialInterface<JvarMapKernelInterface<SusceptibilityTimeDerivativeBase<is_ad>>>(
      34             :         parameters),
      35         274 :     _Chi(this->template getGenericMaterialProperty<Real, is_ad>("f_name"))
      36             : {
      37         137 : }
      38             : 
      39         111 : SusceptibilityTimeDerivative::SusceptibilityTimeDerivative(const InputParameters & parameters)
      40             :   : SusceptibilityTimeDerivativeTempl<false>(parameters),
      41         111 :     _dChidu(getMaterialPropertyDerivative<Real>("f_name", _var.name())),
      42         222 :     _dChidarg(_n_args)
      43             : {
      44             :   // fetch derivatives
      45         303 :   for (unsigned int i = 0; i < _n_args; ++i)
      46         192 :     _dChidarg[i] = &getMaterialPropertyDerivative<Real>("f_name", i);
      47         111 : }
      48             : 
      49             : void
      50          84 : SusceptibilityTimeDerivative::initialSetup()
      51             : {
      52         252 :   validateNonlinearCoupling<Real>("f_name");
      53          84 : }
      54             : 
      55             : Real
      56     3932080 : SusceptibilityTimeDerivative::computeQpResidual()
      57             : {
      58     3932080 :   return TimeDerivative::computeQpResidual() * _Chi[_qp];
      59             : }
      60             : 
      61             : ADReal
      62      167740 : ADSusceptibilityTimeDerivative::precomputeQpResidual()
      63             : {
      64      167740 :   return _u_dot[_qp] * _Chi[_qp];
      65             : }
      66             : 
      67             : Real
      68     4561216 : SusceptibilityTimeDerivative::computeQpJacobian()
      69             : {
      70     4561216 :   return TimeDerivative::computeQpJacobian() * _Chi[_qp] +
      71     4561216 :          TimeDerivative::computeQpResidual() * _dChidu[_qp] * _phi[_j][_qp];
      72             : }
      73             : 
      74             : Real
      75     1628800 : SusceptibilityTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar)
      76             : {
      77             :   // get the coupled variable jvar is referring to
      78             :   const unsigned int cvar = mapJvarToCvar(jvar);
      79             : 
      80     1628800 :   return TimeDerivative::computeQpResidual() * (*_dChidarg[cvar])[_qp] * _phi[_j][_qp];
      81             : }

Generated by: LCOV version 1.14