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

Generated by: LCOV version 1.14