LCOV - code coverage report
Current view: top level - src/interfacekernels - EqualGradientLagrangeMultiplier.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 27 28 96.4 %
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 "EqualGradientLagrangeMultiplier.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseVariable.h"
      14             : 
      15             : registerMooseObject("PhaseFieldApp", EqualGradientLagrangeMultiplier);
      16             : 
      17             : InputParameters
      18          23 : EqualGradientLagrangeMultiplier::validParams()
      19             : {
      20          23 :   InputParameters params = InterfaceKernel::validParams();
      21          23 :   params.addClassDescription("Lagrange multiplier kernel for EqualGradientLagrangeInterface.");
      22          46 :   params.addRequiredParam<unsigned int>("component", "Gradient component to constrain");
      23          46 :   params.addCoupledVar("element_var",
      24             :                        "The gradient constrained variable on this side of the interface.");
      25          46 :   params.addParam<Real>("jacobian_fill",
      26          46 :                         0.0,
      27             :                         "Compensate on diagonal Jacobian fill term when "
      28             :                         "using a NullKernel on the Lagrange multiplier "
      29             :                         "variable");
      30          23 :   return params;
      31           0 : }
      32             : 
      33          12 : EqualGradientLagrangeMultiplier::EqualGradientLagrangeMultiplier(const InputParameters & parameters)
      34             :   : InterfaceKernel(parameters),
      35          12 :     _component(getParam<unsigned int>("component")),
      36          12 :     _grad_element_value(getVar("element_var", 0)->gradSln()),
      37          12 :     _element_jvar(getVar("element_var", 0)->number()),
      38          12 :     _neighbor_jvar(_neighbor_var.number()),
      39          36 :     _jacobian_fill(getParam<Real>("jacobian_fill"))
      40             : {
      41          12 : }
      42             : 
      43             : Real
      44      214400 : EqualGradientLagrangeMultiplier::computeQpResidual(Moose::DGResidualType type)
      45             : {
      46      214400 :   if (type == Moose::Element)
      47      107200 :     return (_grad_element_value[_qp](_component) - _grad_neighbor_value[_qp](_component)) *
      48      107200 :            _test[_i][_qp];
      49             : 
      50             :   return 0.0;
      51             : }
      52             : 
      53             : Real
      54      156160 : EqualGradientLagrangeMultiplier::computeQpJacobian(Moose::DGJacobianType type)
      55             : {
      56      156160 :   if (type == Moose::ElementNeighbor)
      57       39040 :     return -_grad_phi_neighbor[_j][_qp](_component) * _test[_i][_qp];
      58             : 
      59      117120 :   if (type == Moose::ElementElement)
      60       39040 :     return -_jacobian_fill;
      61             : 
      62             :   return 0.0;
      63             : }
      64             : 
      65             : Real
      66       78080 : EqualGradientLagrangeMultiplier::computeQpOffDiagJacobian(Moose::DGJacobianType type,
      67             :                                                           unsigned int jvar)
      68             : {
      69       78080 :   if (type == Moose::ElementElement && jvar == _element_jvar)
      70       39040 :     return _grad_phi[_j][_qp](_component) * _test[_i][_qp];
      71             : 
      72             :   return 0.0;
      73             : }

Generated by: LCOV version 1.14