LCOV - code coverage report
Current view: top level - src/interfacekernels - PenaltyInterfaceDiffusion.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 43 44 97.7 %
Date: 2026-05-29 20:35:17 Functions: 12 16 75.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 "PenaltyInterfaceDiffusion.h"
      11             : 
      12             : registerMooseObject("MooseApp", PenaltyInterfaceDiffusion);
      13             : registerMooseObject("MooseApp", ADPenaltyInterfaceDiffusion);
      14             : registerMooseObject("MooseApp", VectorPenaltyInterfaceDiffusion);
      15             : registerMooseObject("MooseApp", ADVectorPenaltyInterfaceDiffusion);
      16             : 
      17             : template <typename T, bool is_ad>
      18             : InputParameters
      19       12824 : PenaltyInterfaceDiffusionTempl<T, is_ad>::validParams()
      20             : {
      21       12824 :   InputParameters params = GenericInterfaceKernelTempl<T, is_ad>::validParams();
      22       51296 :   params.addRequiredParam<Real>(
      23             :       "penalty", "The penalty that penalizes jump between primary and neighbor variables.");
      24       51296 :   params.addParam<MaterialPropertyName>(
      25             :       "jump_prop_name", "the name of the material property that calculates the jump.");
      26       12824 :   params.addClassDescription(
      27             :       "A penalty-based interface condition that forces"
      28             :       "the continuity of variables and the flux equivalence across an interface.");
      29       12824 :   return params;
      30           0 : }
      31             : 
      32             : template <typename T, bool is_ad>
      33         303 : PenaltyInterfaceDiffusionTempl<T, is_ad>::PenaltyInterfaceDiffusionTempl(
      34             :     const InputParameters & parameters)
      35             :   : GenericInterfaceKernelTempl<T, is_ad>(parameters),
      36         303 :     _penalty(this->template getParam<Real>("penalty")),
      37         606 :     _jump(isParamValid("jump_prop_name")
      38         469 :               ? &this->template getGenericMaterialProperty<T, is_ad>("jump_prop_name")
      39         606 :               : nullptr)
      40             : {
      41         303 : }
      42             : 
      43             : template <typename T, bool is_ad>
      44             : GenericReal<is_ad>
      45       64272 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpResidual(Moose::DGResidualType type)
      46             : {
      47       64272 :   GenericReal<is_ad> r = 0;
      48             : 
      49       64272 :   Moose::GenericType<T, is_ad> jump_value = 0;
      50             : 
      51       64272 :   if (_jump != nullptr)
      52        8064 :     jump_value = (*_jump)[_qp];
      53             :   else
      54       56208 :     jump_value = _u[_qp] - _neighbor_value[_qp];
      55             : 
      56       64272 :   switch (type)
      57             :   {
      58       32248 :     case Moose::Element:
      59       32248 :       r = _test[_i][_qp] * _penalty * jump_value;
      60       32248 :       break;
      61             : 
      62       32024 :     case Moose::Neighbor:
      63       32024 :       r = _test_neighbor[_i][_qp] * -_penalty * jump_value;
      64       32024 :       break;
      65             :   }
      66             : 
      67       64368 :   return r;
      68          96 : }
      69             : 
      70             : template <typename T, bool is_ad>
      71             : Real
      72      397184 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpJacobian(Moose::DGJacobianType type)
      73             : {
      74      397184 :   Real jac = 0;
      75             : 
      76      397184 :   switch (type)
      77             :   {
      78       99416 :     case Moose::ElementElement:
      79       99416 :       jac = _test[_i][_qp] * _penalty * _phi[_j][_qp];
      80       99416 :       break;
      81             : 
      82       99256 :     case Moose::ElementNeighbor:
      83       99256 :       jac = _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp];
      84       99256 :       break;
      85             : 
      86       99256 :     case Moose::NeighborElement:
      87       99256 :       jac = _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp];
      88       99256 :       break;
      89             : 
      90       99256 :     case Moose::NeighborNeighbor:
      91       99256 :       jac = _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp];
      92       99256 :       break;
      93             :   }
      94             : 
      95      397184 :   return jac;
      96             : }
      97             : 
      98             : template class PenaltyInterfaceDiffusionTempl<Real, false>;
      99             : template class PenaltyInterfaceDiffusionTempl<Real, true>;
     100             : template class PenaltyInterfaceDiffusionTempl<RealVectorValue, false>;
     101             : template class PenaltyInterfaceDiffusionTempl<RealVectorValue, true>;

Generated by: LCOV version 1.14