LCOV - code coverage report
Current view: top level - src/kernels - KKSPhaseConcentration.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 29 30 96.7 %
Date: 2026-05-29 20:38:39 Functions: 5 5 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 "KKSPhaseConcentration.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", KKSPhaseConcentration);
      13             : 
      14             : InputParameters
      15         108 : KKSPhaseConcentration::validParams()
      16             : {
      17         108 :   InputParameters params = Kernel::validParams();
      18         108 :   params.addClassDescription("KKS model kernel to enforce the decomposition of concentration into "
      19             :                              "phase concentration  $(1-h(\\eta))c_a + h(\\eta)c_b - c = 0$. The "
      20             :                              "non-linear variable of this kernel is $c_b$.");
      21         216 :   params.addRequiredCoupledVar("ca", "Phase a concentration");
      22         216 :   params.addRequiredCoupledVar("c", "Real concentration");
      23         216 :   params.addRequiredCoupledVar("eta", "Phase a/b order parameter");
      24         216 :   params.addParam<MaterialPropertyName>(
      25             :       "h_name", "h", "Base name for the switching function h(eta)");
      26         108 :   return params;
      27           0 : }
      28             : 
      29             : // Phase interpolation func
      30          58 : KKSPhaseConcentration::KKSPhaseConcentration(const InputParameters & parameters)
      31             :   : DerivativeMaterialInterface<Kernel>(parameters),
      32          58 :     _ca(coupledValue("ca")),
      33          58 :     _ca_var(coupled("ca")),
      34          58 :     _c(coupledValue("c")),
      35          58 :     _c_var(coupled("c")),
      36          58 :     _eta(coupledValue("eta")),
      37          58 :     _eta_var(coupled("eta")),
      38         116 :     _prop_h(getMaterialProperty<Real>("h_name")),
      39         174 :     _prop_dh(getMaterialPropertyDerivative<Real>("h_name", coupledName("eta", 0)))
      40             : {
      41          58 : }
      42             : 
      43             : Real
      44     4509760 : KKSPhaseConcentration::computeQpResidual()
      45             : {
      46             :   // R = (1-h(eta))*ca + h(eta)*cb - c
      47     4509760 :   return _test[_i][_qp] * ((1.0 - _prop_h[_qp]) * _ca[_qp] + _prop_h[_qp] * _u[_qp] - _c[_qp]);
      48             : }
      49             : 
      50             : Real
      51     2720000 : KKSPhaseConcentration::computeQpJacobian()
      52             : {
      53     2720000 :   return _test[_i][_qp] * _prop_h[_qp] * _phi[_j][_qp];
      54             : }
      55             : 
      56             : Real
      57     9856000 : KKSPhaseConcentration::computeQpOffDiagJacobian(unsigned int jvar)
      58             : {
      59     9856000 :   if (jvar == _ca_var)
      60     2720000 :     return _test[_i][_qp] * (1.0 - _prop_h[_qp]) * _phi[_j][_qp];
      61             : 
      62     7136000 :   else if (jvar == _c_var)
      63     2720000 :     return -_test[_i][_qp] * _phi[_j][_qp];
      64             : 
      65     4416000 :   else if (jvar == _eta_var)
      66     2720000 :     return _test[_i][_qp] * (_u[_qp] - _ca[_qp]) * _prop_dh[_qp] * _phi[_j][_qp];
      67             : 
      68             :   return 0.0;
      69             : }

Generated by: LCOV version 1.14