LCOV - code coverage report
Current view: top level - src/kernels - ADACInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 34 36 94.4 %
Date: 2026-05-29 20:38:39 Functions: 3 3 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 "ADACInterface.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", ADACInterface);
      13             : 
      14             : InputParameters
      15         255 : ADACInterface::validParams()
      16             : {
      17         255 :   InputParameters params = ADKernel::validParams();
      18         255 :   params.addClassDescription("Gradient energy Allen-Cahn Kernel");
      19         510 :   params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
      20         510 :   params.addParam<MaterialPropertyName>("kappa_name", "kappa_op", "The kappa used with the kernel");
      21         510 :   params.addCoupledVar("coupled_variables",
      22             :                        "Vector of nonlinear variable arguments this object depends on");
      23             : 
      24         510 :   params.addParam<bool>("variable_L",
      25         510 :                         true,
      26             :                         "The mobility is a function of any MOOSE variable (if "
      27             :                         "this is set to false L must be constant over the "
      28             :                         "entire domain!)");
      29         255 :   return params;
      30           0 : }
      31             : 
      32         138 : ADACInterface::ADACInterface(const InputParameters & parameters)
      33             :   : ADKernel(parameters),
      34         138 :     _prop_L(getADMaterialProperty<Real>("mob_name")),
      35         276 :     _name_L(getParam<MaterialPropertyName>("mob_name")),
      36         276 :     _kappa(getADMaterialProperty<Real>("kappa_name")),
      37         276 :     _variable_L(getParam<bool>("variable_L")),
      38         276 :     _dLdop(_variable_L
      39         164 :                ? &getADMaterialProperty<Real>(derivativePropertyNameFirst(_name_L, _var.name()))
      40             :                : nullptr),
      41         138 :     _nvar(Coupleable::_coupled_standard_moose_vars.size()),
      42         138 :     _dLdarg(_nvar),
      43         276 :     _gradarg(_nvar)
      44             : {
      45             :   // Get mobility and kappa derivatives and coupled variable gradients
      46         138 :   if (_variable_L)
      47          26 :     for (unsigned int i = 0; i < _nvar; ++i)
      48             :     {
      49          13 :       MooseVariable * ivar = _coupled_standard_moose_vars[i];
      50             :       const VariableName iname = ivar->name();
      51          13 :       if (iname == _var.name())
      52           0 :         paramError("coupled_variables",
      53             :                    "The kernel variable should not be specified in the coupled `coupled_variables` "
      54             :                    "parameter.");
      55             : 
      56          26 :       _dLdarg[i] = &getADMaterialProperty<Real>(derivativePropertyNameFirst(_name_L, iname));
      57          13 :       _gradarg[i] = &(ivar->adGradSln());
      58             :     }
      59         138 : }
      60             : 
      61             : ADReal
      62   160115280 : ADACInterface::computeQpResidual()
      63             : {
      64             :   // nabla_Lpsi is the product rule gradient \f$ \nabla (L\psi) \f$
      65   160115280 :   ADRealVectorValue nabla_Lpsi = _prop_L[_qp] * _grad_test[_i][_qp];
      66             : 
      67   160115280 :   if (_variable_L)
      68             :   {
      69     2563200 :     ADRealVectorValue grad_L = _grad_u[_qp] * (*_dLdop)[_qp];
      70     5126400 :     for (unsigned int i = 0; i < _nvar; ++i)
      71     5126400 :       grad_L += (*_gradarg[i])[_qp] * (*_dLdarg[i])[_qp];
      72             : 
      73     5126400 :     nabla_Lpsi += grad_L * _test[_i][_qp];
      74             :   }
      75             : 
      76   160115280 :   return _grad_u[_qp] * _kappa[_qp] * nabla_Lpsi;
      77             : }

Generated by: LCOV version 1.14