LCOV - code coverage report
Current view: top level - src/kernels - JouleHeatingSource.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 29 32 90.6 %
Date: 2025-09-04 07:53:51 Functions: 6 6 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 "JouleHeatingSource.h"
      11             : 
      12             : registerMooseObject("HeatTransferApp", JouleHeatingSource);
      13             : 
      14             : InputParameters
      15          41 : JouleHeatingSource::validParams()
      16             : {
      17             :   InputParameters params =
      18          41 :       DerivativeMaterialInterface<JvarMapKernelInterface<HeatSource>>::validParams();
      19          82 :   params.addCoupledVar("elec", "Electric potential for joule heating.");
      20          82 :   params.addParam<MaterialPropertyName>(
      21             :       "electrical_conductivity",
      22             :       "electrical_conductivity",
      23             :       "Material property providing electrical conductivity of the material.");
      24          41 :   params.addClassDescription("Calculates the heat source term corresponding to electrostatic Joule "
      25             :                              "heating.");
      26          41 :   return params;
      27           0 : }
      28             : 
      29          22 : JouleHeatingSource::JouleHeatingSource(const InputParameters & parameters)
      30             :   : DerivativeMaterialInterface<JvarMapKernelInterface<HeatSource>>(parameters),
      31          22 :     _grad_elec(coupledGradient("elec")),
      32          22 :     _elec_var(coupled("elec")),
      33          44 :     _elec_cond(getMaterialProperty<Real>("electrical_conductivity")),
      34          22 :     _delec_cond_dT(getMaterialPropertyDerivative<Real>("electrical_conductivity", _var.name())),
      35          44 :     _delec_cond_darg(_coupled_moose_vars.size())
      36             : {
      37          44 :   for (unsigned int i = 0; i < _delec_cond_darg.size(); ++i)
      38          22 :     _delec_cond_darg[i] = &getMaterialPropertyDerivative<Real>("electrical_conductivity",
      39          22 :                                                                _coupled_moose_vars[i]->name());
      40             : 
      41          22 :   mooseDeprecated("The non-AD version of JouleHeatingSource will be deprecated in the near future "
      42             :                   "(10/01/2025) in favor of exclusively using the AD version of "
      43             :                   "JouleHeatingSource, since the ADJouleHeatingSource can calculate both "
      44             :                   "electrostatic and electromagnetic Joule heating.");
      45          22 : }
      46             : 
      47             : void
      48          22 : JouleHeatingSource::initialSetup()
      49             : {
      50          66 :   validateNonlinearCoupling<Real>("electrical_conductivity");
      51          22 : }
      52             : 
      53             : Real
      54     1604800 : JouleHeatingSource::computeQpResidual()
      55             : {
      56     1604800 :   return -_elec_cond[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _test[_i][_qp];
      57             : }
      58             : 
      59             : Real
      60      966400 : JouleHeatingSource::computeQpJacobian()
      61             : {
      62      966400 :   return -_delec_cond_dT[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] * _test[_i][_qp];
      63             : }
      64             : 
      65             : Real
      66      889600 : JouleHeatingSource::computeQpOffDiagJacobian(unsigned int jvar)
      67             : {
      68             :   const unsigned int cvar = mapJvarToCvar(jvar);
      69             : 
      70      889600 :   if (jvar == _elec_var)
      71      889600 :     return -2 * _elec_cond[_qp] * _grad_elec[_qp] * _grad_phi[_j][_qp] * _test[_i][_qp] -
      72      889600 :            (*_delec_cond_darg[cvar])[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] *
      73      889600 :                _test[_i][_qp];
      74             : 
      75           0 :   return -(*_delec_cond_darg[cvar])[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] *
      76           0 :          _test[_i][_qp];
      77             : }

Generated by: LCOV version 1.14