LCOV - code coverage report
Current view: top level - src/kernels - KKSMultiACBulkF.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 30 32 93.8 %
Date: 2026-05-29 20:38:39 Functions: 4 4 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 "KKSMultiACBulkF.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", KKSMultiACBulkF);
      13             : 
      14             : InputParameters
      15         206 : KKSMultiACBulkF::validParams()
      16             : {
      17         206 :   InputParameters params = KKSMultiACBulkBase::validParams();
      18         206 :   params.addClassDescription("KKS model kernel (part 1 of 2) for the Bulk Allen-Cahn. This "
      19             :                              "includes all terms NOT dependent on chemical potential.");
      20         412 :   params.addRequiredParam<Real>("wi", "Double well height parameter");
      21         412 :   params.addRequiredParam<MaterialPropertyName>(
      22             :       "gi_name", "Base name for the double well function g_i(eta_i)");
      23         206 :   return params;
      24           0 : }
      25             : 
      26         110 : KKSMultiACBulkF::KKSMultiACBulkF(const InputParameters & parameters)
      27             :   : KKSMultiACBulkBase(parameters),
      28         110 :     _wi(getParam<Real>("wi")),
      29         110 :     _prop_dgi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name)),
      30         220 :     _prop_d2gi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name, _etai_name))
      31             : {
      32         110 : }
      33             : 
      34             : Real
      35    39706000 : KKSMultiACBulkF::computeDFDOP(PFFunctionType type)
      36             : {
      37             :   Real sum = 0.0;
      38             : 
      39    39706000 :   switch (type)
      40             :   {
      41             :     case Residual:
      42   148752880 :       for (unsigned int n = 0; n < _num_j; ++n)
      43   110772320 :         sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
      44             : 
      45    37980560 :       return sum + _wi * _prop_dgi[_qp];
      46             : 
      47     1725440 :     case Jacobian:
      48             :       // For when this kernel is used in the Lagrange multiplier equation
      49             :       // In that case the Lagrange multiplier is the nonlinear variable
      50     1725440 :       if (_etai_var != _var.number())
      51             :         return 0.0;
      52             : 
      53             :       // For when eta_i is the nonlinear variable
      54     2920960 :       for (unsigned int n = 0; n < _num_j; ++n)
      55     2135040 :         sum += (*_prop_d2hjdetai2[n])[_qp] * (*_prop_Fj[n])[_qp];
      56             : 
      57      785920 :       return _phi[_j][_qp] * (sum + _wi * _prop_d2gi[_qp]);
      58             :   }
      59             : 
      60           0 :   mooseError("Invalid type passed in");
      61             : }
      62             : 
      63             : Real
      64    34038880 : KKSMultiACBulkF::computeQpOffDiagJacobian(unsigned int jvar)
      65             : {
      66             :   // get the coupled variable jvar is referring to
      67             :   const unsigned int cvar = mapJvarToCvar(jvar);
      68             : 
      69             :   // first get dependence of mobility _L on other variables using parent class
      70             :   // member function
      71    34038880 :   Real res = ACBulk<Real>::computeQpOffDiagJacobian(jvar);
      72             : 
      73             :   // Then add dependence of KKSMultiACBulkF on other variables
      74             :   Real sum = 0.0;
      75   133655840 :   for (unsigned int n = 0; n < _num_j; ++n)
      76    99616960 :     sum += (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_prop_Fj[n])[_qp] +
      77    99616960 :            (*_prop_dhjdetai[n])[_qp] * (*_prop_dFjdarg[n][cvar])[_qp];
      78             : 
      79             :   // Handle the case when this kernel is used in the Lagrange multiplier equation
      80             :   // In this case the second derivative of the barrier function contributes
      81             :   // to the off-diagonal Jacobian
      82    34038880 :   if (jvar == _etai_var)
      83     3568640 :     sum += _wi * _prop_d2gi[_qp];
      84             : 
      85    34038880 :   res += _L[_qp] * sum * _phi[_j][_qp] * _test[_i][_qp];
      86             : 
      87    34038880 :   return res;
      88             : }

Generated by: LCOV version 1.14