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

Generated by: LCOV version 1.14