LCOV - code coverage report
Current view: top level - src/kernels - CoupledMaterialDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 24 25 96.0 %
Date: 2025-09-04 07:55:36 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 "CoupledMaterialDerivative.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", CoupledMaterialDerivative);
      13             : 
      14             : InputParameters
      15          46 : CoupledMaterialDerivative::validParams()
      16             : {
      17          46 :   InputParameters params = JvarMapKernelInterface<Kernel>::validParams();
      18          46 :   params.addClassDescription("Kernel that implements the first derivative of a function material "
      19             :                              "property with respect to a coupled variable.");
      20          92 :   params.addRequiredCoupledVar("v", "Variable to take the derivative with respect to");
      21          92 :   params.addParam<MaterialPropertyName>("f_name",
      22             :                                         "F",
      23             :                                         "Function material to take the derivative of (should "
      24             :                                         "provide derivative properties - such as a "
      25             :                                         "DerivativeParsedMaterial)");
      26          46 :   return params;
      27           0 : }
      28             : 
      29          24 : CoupledMaterialDerivative::CoupledMaterialDerivative(const InputParameters & parameters)
      30             :   : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
      31          24 :     _v_name(coupledName("v", 0)),
      32          24 :     _v_var(coupled("v")),
      33          24 :     _dFdv(getMaterialPropertyDerivative<Real>("f_name", _v_name)),
      34          24 :     _d2Fdvdu(getMaterialPropertyDerivative<Real>("f_name", _v_name, _var.name())),
      35          48 :     _d2Fdvdarg(_n_args)
      36             : {
      37             :   // Get material property derivatives for all coupled variables
      38          48 :   for (unsigned int i = 0; i < _n_args; ++i)
      39          24 :     _d2Fdvdarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _v_name, i);
      40          24 : }
      41             : 
      42             : void
      43          24 : CoupledMaterialDerivative::initialSetup()
      44             : {
      45          72 :   validateNonlinearCoupling<Real>("f_name");
      46          24 : }
      47             : 
      48             : Real
      49     4636800 : CoupledMaterialDerivative::computeQpResidual()
      50             : {
      51     4636800 :   return _dFdv[_qp] * _test[_i][_qp];
      52             : }
      53             : 
      54             : Real
      55    14976000 : CoupledMaterialDerivative::computeQpJacobian()
      56             : {
      57    14976000 :   return _d2Fdvdu[_qp] * _test[_i][_qp] * _phi[_j][_qp];
      58             : }
      59             : 
      60             : Real
      61    14976000 : CoupledMaterialDerivative::computeQpOffDiagJacobian(unsigned int jvar)
      62             : {
      63             :   const unsigned int cvar = mapJvarToCvar(jvar);
      64    14976000 :   return (*_d2Fdvdarg[cvar])[_qp] * _test[_i][_qp] * _phi[_j][_qp];
      65             : }

Generated by: LCOV version 1.14