LCOV - code coverage report
Current view: top level - src/kernels - SplitCHParsed.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 28 30 93.3 %
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 "SplitCHParsed.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", SplitCHParsed);
      13             : 
      14             : InputParameters
      15        1003 : SplitCHParsed::validParams()
      16             : {
      17        1003 :   InputParameters params = SplitCHCRes::validParams();
      18        1003 :   params.addClassDescription(
      19             :       "Split formulation Cahn-Hilliard Kernel that uses a DerivativeMaterial Free Energy");
      20        2006 :   params.addRequiredParam<MaterialPropertyName>(
      21             :       "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial");
      22        2006 :   params.addCoupledVar("args", "Vector of additional variable arguments to F");
      23        2006 :   params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
      24             : 
      25        1003 :   return params;
      26           0 : }
      27             : 
      28         525 : SplitCHParsed::SplitCHParsed(const InputParameters & parameters)
      29             :   : DerivativeMaterialInterface<JvarMapKernelInterface<SplitCHCRes>>(parameters),
      30         525 :     _dFdc(getMaterialPropertyDerivative<Real>("f_name", _var.name())),
      31         525 :     _d2Fdc2(getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name())),
      32        1050 :     _d2Fdcdarg(_n_args)
      33             : {
      34             :   // Iterate over all coupled variables
      35        1311 :   for (unsigned int i = 0; i < _n_args; ++i)
      36         786 :     _d2Fdcdarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _var.name(), i);
      37         525 : }
      38             : 
      39             : void
      40         417 : SplitCHParsed::initialSetup()
      41             : {
      42             :   /**
      43             :    * We are only interested if the necessary non-linear variables are coupled,
      44             :    * as those are thge ones used in constructing the Jacobian. The AuxVariables
      45             :    * do not have Jacobian entries.
      46             :    */
      47        1668 :   validateNonlinearCoupling<Real>("f_name", _var.name());
      48         417 :   validateDerivativeMaterialPropertyBase<Real>("f_name");
      49         417 : }
      50             : 
      51             : Real
      52   234379935 : SplitCHParsed::computeDFDC(PFFunctionType type)
      53             : {
      54   234379935 :   switch (type)
      55             :   {
      56    54210599 :     case Residual:
      57    54210599 :       return _dFdc[_qp];
      58             : 
      59   180169336 :     case Jacobian:
      60   180169336 :       return _d2Fdc2[_qp] * _phi[_j][_qp];
      61             :   }
      62             : 
      63           0 :   mooseError("Internal error");
      64             : }
      65             : 
      66             : Real
      67   217762232 : SplitCHParsed::computeQpOffDiagJacobian(unsigned int jvar)
      68             : {
      69   217762232 :   if (jvar == _w_var)
      70   180169336 :     return SplitCHCRes::computeQpOffDiagJacobian(jvar);
      71             : 
      72             :   // get the coupled variable jvar is referring to
      73             :   const unsigned int cvar = mapJvarToCvar(jvar);
      74             : 
      75    37592896 :   return (*_d2Fdcdarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
      76             : }

Generated by: LCOV version 1.14