LCOV - code coverage report
Current view: top level - src/kernels - KKSMultiACBulkF.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 30 32 93.8 %
Date: 2025-09-04 07:55:36 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         310 : KKSMultiACBulkF::validParams()
      16             : {
      17         310 :   InputParameters params = KKSMultiACBulkBase::validParams();
      18         310 :   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         620 :   params.addRequiredParam<Real>("wi", "Double well height parameter");
      21         620 :   params.addRequiredParam<MaterialPropertyName>(
      22             :       "gi_name", "Base name for the double well function g_i(eta_i)");
      23         310 :   return params;
      24           0 : }
      25             : 
      26         162 : KKSMultiACBulkF::KKSMultiACBulkF(const InputParameters & parameters)
      27             :   : KKSMultiACBulkBase(parameters),
      28         162 :     _wi(getParam<Real>("wi")),
      29         162 :     _prop_dgi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name)),
      30         324 :     _prop_d2gi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name, _etai_name))
      31             : {
      32         162 : }
      33             : 
      34             : Real
      35    47407760 : KKSMultiACBulkF::computeDFDOP(PFFunctionType type)
      36             : {
      37             :   Real sum = 0.0;
      38             : 
      39    47407760 :   switch (type)
      40             :   {
      41             :     case Residual:
      42   177242960 :       for (unsigned int n = 0; n < _num_j; ++n)
      43   131879840 :         sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
      44             : 
      45    45363120 :       return sum + _wi * _prop_dgi[_qp];
      46             : 
      47     2044640 :     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     2044640 :       if (_etai_var != _var.number())
      51             :         return 0.0;
      52             : 
      53             :       // For when eta_i is the nonlinear variable
      54     3463520 :       for (unsigned int n = 0; n < _num_j; ++n)
      55     2530880 :         sum += (*_prop_d2hjdetai2[n])[_qp] * (*_prop_Fj[n])[_qp];
      56             : 
      57      932640 :       return _phi[_j][_qp] * (sum + _wi * _prop_d2gi[_qp]);
      58             :   }
      59             : 
      60           0 :   mooseError("Invalid type passed in");
      61             : }
      62             : 
      63             : Real
      64    40271680 : 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    40271680 :   Real res = ACBulk<Real>::computeQpOffDiagJacobian(jvar);
      72             : 
      73             :   // Then add dependence of KKSMultiACBulkF on other variables
      74             :   Real sum = 0.0;
      75   158088640 :   for (unsigned int n = 0; n < _num_j; ++n)
      76   117816960 :     sum += (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_prop_Fj[n])[_qp] +
      77   117816960 :            (*_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    40271680 :   if (jvar == _etai_var)
      83     4220800 :     sum += _wi * _prop_d2gi[_qp];
      84             : 
      85    40271680 :   res += _L[_qp] * sum * _phi[_j][_qp] * _test[_i][_qp];
      86             : 
      87    40271680 :   return res;
      88             : }

Generated by: LCOV version 1.14