LCOV - code coverage report
Current view: top level - src/kernels - SusceptibilityTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31761 (b7bd6c) with base 2acb41 Lines: 27 28 96.4 %
Date: 2025-10-28 02:30:14 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("coupled_variables", "Vector of variable arguments of the susceptibility");
      26         261 :   return params;
      27           0 : }
      28             : 
      29             : template <bool is_ad>
      30         137 : SusceptibilityTimeDerivativeTempl<is_ad>::SusceptibilityTimeDerivativeTempl(
      31             :     const InputParameters & parameters)
      32             :   : DerivativeMaterialInterface<JvarMapKernelInterface<SusceptibilityTimeDerivativeBase<is_ad>>>(
      33             :         parameters),
      34         274 :     _Chi(this->template getGenericMaterialProperty<Real, is_ad>("f_name"))
      35             : {
      36         137 : }
      37             : 
      38         111 : SusceptibilityTimeDerivative::SusceptibilityTimeDerivative(const InputParameters & parameters)
      39             :   : SusceptibilityTimeDerivativeTempl<false>(parameters),
      40         111 :     _dChidu(getMaterialPropertyDerivative<Real>("f_name", _var.name())),
      41         222 :     _dChidarg(_n_args)
      42             : {
      43             :   // fetch derivatives
      44         303 :   for (unsigned int i = 0; i < _n_args; ++i)
      45         192 :     _dChidarg[i] = &getMaterialPropertyDerivative<Real>("f_name", i);
      46         111 : }
      47             : 
      48             : void
      49          84 : SusceptibilityTimeDerivative::initialSetup()
      50             : {
      51         252 :   validateNonlinearCoupling<Real>("f_name");
      52          84 : }
      53             : 
      54             : Real
      55     3932080 : SusceptibilityTimeDerivative::computeQpResidual()
      56             : {
      57     3932080 :   return TimeDerivative::computeQpResidual() * _Chi[_qp];
      58             : }
      59             : 
      60             : ADReal
      61      167740 : ADSusceptibilityTimeDerivative::precomputeQpResidual()
      62             : {
      63      167740 :   return _u_dot[_qp] * _Chi[_qp];
      64             : }
      65             : 
      66             : Real
      67     4561216 : SusceptibilityTimeDerivative::computeQpJacobian()
      68             : {
      69     4561216 :   return TimeDerivative::computeQpJacobian() * _Chi[_qp] +
      70     4561216 :          TimeDerivative::computeQpResidual() * _dChidu[_qp] * _phi[_j][_qp];
      71             : }
      72             : 
      73             : Real
      74     1628800 : SusceptibilityTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar)
      75             : {
      76             :   // get the coupled variable jvar is referring to
      77             :   const unsigned int cvar = mapJvarToCvar(jvar);
      78             : 
      79     1628800 :   return TimeDerivative::computeQpResidual() * (*_dChidarg[cvar])[_qp] * _phi[_j][_qp];
      80             : }

Generated by: LCOV version 1.14