LCOV - code coverage report
Current view: top level - src/interfacekernels - CoupledPenaltyInterfaceDiffusion.C (source / functions) Hit Total Coverage
Test: idaholab/moose fsi: #32971 (54bef8) with base c6cf66 Lines: 50 53 94.3 %
Date: 2026-05-29 20:36:35 Functions: 6 7 85.7 %
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 "CoupledPenaltyInterfaceDiffusion.h"
      11             : 
      12             : registerMooseObject("FsiApp", CoupledPenaltyInterfaceDiffusion);
      13             : 
      14             : InputParameters
      15          38 : CoupledPenaltyInterfaceDiffusion::validParams()
      16             : {
      17          38 :   InputParameters params = InterfaceKernel::validParams();
      18          38 :   params.addClassDescription(
      19             :       "Enforces continuity of flux and continuity of solution via penalty across an interface.");
      20          76 :   params.addRequiredParam<Real>(
      21             :       "penalty",
      22             :       "The penalty that penalizes jump between primary and neighbor secondary variables.");
      23          76 :   params.addCoupledVar("primary_coupled_var", "The coupled variable on the primary side");
      24          76 :   params.addCoupledVar("secondary_coupled_var", "The coupled variable on the secondary side");
      25          38 :   return params;
      26           0 : }
      27             : 
      28          20 : CoupledPenaltyInterfaceDiffusion::CoupledPenaltyInterfaceDiffusion(
      29          20 :     const InputParameters & parameters)
      30             :   : InterfaceKernel(parameters),
      31          20 :     _penalty(getParam<Real>("penalty")),
      32          40 :     _primary_coupled_value(isCoupled("primary_coupled_var") ? coupledValue("primary_coupled_var")
      33          20 :                                                             : _var.sln()),
      34          20 :     _secondary_coupled_value(isCoupled("secondary_coupled_var")
      35          40 :                                  ? coupledNeighborValue("secondary_coupled_var")
      36           0 :                                  : _neighbor_var.slnNeighbor()),
      37          40 :     _primary_coupled_id(isCoupled("primary_coupled_var") ? coupled("primary_coupled_var")
      38          20 :                                                          : _var.number()),
      39          40 :     _secondary_coupled_id(isCoupled("secondary_coupled_var") ? coupled("secondary_coupled_var")
      40          20 :                                                              : _neighbor_var.number())
      41             : {
      42          20 : }
      43             : 
      44             : Real
      45     3134080 : CoupledPenaltyInterfaceDiffusion::computeQpResidual(Moose::DGResidualType type)
      46             : {
      47             :   Real r = 0;
      48             : 
      49     3134080 :   switch (type)
      50             :   {
      51     1567040 :     case Moose::Element:
      52     1567040 :       r = _test[_i][_qp] * _penalty * (_primary_coupled_value[_qp] - _secondary_coupled_value[_qp]);
      53     1567040 :       break;
      54             : 
      55     1567040 :     case Moose::Neighbor:
      56     1567040 :       r = _test_neighbor[_i][_qp] * -_penalty *
      57     1567040 :           (_primary_coupled_value[_qp] - _secondary_coupled_value[_qp]);
      58     1567040 :       break;
      59             :   }
      60             : 
      61     3134080 :   return r;
      62             : }
      63             : 
      64           0 : Real CoupledPenaltyInterfaceDiffusion::computeQpJacobian(Moose::DGJacobianType) { return 0; }
      65             : 
      66             : Real
      67      357120 : CoupledPenaltyInterfaceDiffusion::computeQpOffDiagJacobian(Moose::DGJacobianType type,
      68             :                                                            unsigned int jvar)
      69             : {
      70      357120 :   if (jvar == _primary_coupled_id)
      71             :   {
      72       39680 :     switch (type)
      73             :     {
      74       19840 :       case Moose::ElementElement:
      75       19840 :         return _test[_i][_qp] * _penalty * _phi[_j][_qp];
      76       19840 :       case Moose::NeighborElement:
      77       19840 :         return _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp];
      78             :       case Moose::ElementNeighbor:
      79             :       case Moose::NeighborNeighbor:
      80             :         break;
      81             :     }
      82             :   }
      83      317440 :   else if (jvar == _secondary_coupled_id)
      84             :   {
      85       39680 :     switch (type)
      86             :     {
      87       19840 :       case Moose::ElementNeighbor:
      88       19840 :         return _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp];
      89       19840 :       case Moose::NeighborNeighbor:
      90       19840 :         return _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp];
      91             :       case Moose::ElementElement:
      92             :       case Moose::NeighborElement:
      93             :         break;
      94             :     }
      95             :   }
      96             :   return 0;
      97             : }
      98             : 
      99             : void
     100        4340 : CoupledPenaltyInterfaceDiffusion::computeElementOffDiagJacobian(unsigned int jvar)
     101             : {
     102        4340 :   computeOffDiagElemNeighJacobian(Moose::ElementElement, jvar);
     103        4340 :   computeOffDiagElemNeighJacobian(Moose::ElementNeighbor, jvar);
     104        4340 : }
     105             : 
     106             : void
     107        4340 : CoupledPenaltyInterfaceDiffusion::computeNeighborOffDiagJacobian(unsigned int jvar)
     108             : {
     109        4340 :   computeOffDiagElemNeighJacobian(Moose::NeighborElement, jvar);
     110        4340 :   computeOffDiagElemNeighJacobian(Moose::NeighborNeighbor, jvar);
     111        4340 : }

Generated by: LCOV version 1.14