LCOV - code coverage report
Current view: top level - src/kernels - AllenCahn.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 26 28 92.9 %
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 "AllenCahn.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", AllenCahn);
      13             : 
      14             : InputParameters
      15         790 : AllenCahn::validParams()
      16             : {
      17         790 :   InputParameters params = ACBulk<Real>::validParams();
      18         790 :   params.addClassDescription("Allen-Cahn Kernel that uses a DerivativeMaterial Free Energy");
      19        1580 :   params.addRequiredParam<MaterialPropertyName>(
      20             :       "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial");
      21         790 :   return params;
      22           0 : }
      23             : 
      24         422 : AllenCahn::AllenCahn(const InputParameters & parameters)
      25             :   : ACBulk<Real>(parameters),
      26         422 :     _dFdEta(getMaterialPropertyDerivative<Real>("f_name", _var.name())),
      27         422 :     _d2FdEta2(getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name())),
      28         844 :     _d2FdEtadarg(_n_args)
      29             : {
      30             :   // Iterate over all coupled variables
      31        1072 :   for (unsigned int i = 0; i < _n_args; ++i)
      32         650 :     _d2FdEtadarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _var.name(), i);
      33         422 : }
      34             : 
      35             : void
      36         352 : AllenCahn::initialSetup()
      37             : {
      38         352 :   ACBulk<Real>::initialSetup();
      39        1056 :   validateNonlinearCoupling<Real>("f_name");
      40         352 :   validateDerivativeMaterialPropertyBase<Real>("f_name");
      41         352 : }
      42             : 
      43             : Real
      44   248297552 : AllenCahn::computeDFDOP(PFFunctionType type)
      45             : {
      46   248297552 :   switch (type)
      47             :   {
      48   198956464 :     case Residual:
      49   198956464 :       return _dFdEta[_qp];
      50             : 
      51    49341088 :     case Jacobian:
      52    49341088 :       return _d2FdEta2[_qp] * _phi[_j][_qp];
      53             :   }
      54             : 
      55           0 :   mooseError("Internal error");
      56             : }
      57             : 
      58             : Real
      59   129237696 : AllenCahn::computeQpOffDiagJacobian(unsigned int jvar)
      60             : {
      61             :   // get the coupled variable jvar is referring to
      62             :   const unsigned int cvar = mapJvarToCvar(jvar);
      63             : 
      64   129237696 :   return ACBulk<Real>::computeQpOffDiagJacobian(jvar) +
      65   129237696 :          _L[_qp] * (*_d2FdEtadarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
      66             : }

Generated by: LCOV version 1.14