LCOV - code coverage report
Current view: top level - src/constraints - GapConductanceConstraint.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #32971 (54bef8) with base c6cf66 Lines: 35 38 92.1 %
Date: 2026-05-29 20:37:03 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 "GapConductanceConstraint.h"
      11             : 
      12             : registerMooseObject("HeatTransferApp", GapConductanceConstraint);
      13             : 
      14             : InputParameters
      15          54 : GapConductanceConstraint::validParams()
      16             : {
      17          54 :   InputParameters params = ADMortarConstraint::validParams();
      18          54 :   params.addClassDescription(
      19             :       "Computes the residual and Jacobian contributions for the 'Lagrange Multiplier' "
      20             :       "implementation of the thermal contact problem. For more information, see the "
      21             :       "detailed description here: http://tinyurl.com/gmmhbe9");
      22         108 :   params.addRequiredParam<Real>("k", "Gap conductance");
      23         108 :   params.addParam<Real>("min_gap",
      24         108 :                         1e-6,
      25             :                         "The minimum gap distance allowed. This helps with preventing the heat "
      26             :                         "flux from going to infinity as the gap approaches zero.");
      27         108 :   params.addCoupledVar("displacements", "Displacement variables");
      28          54 :   return params;
      29           0 : }
      30             : 
      31          27 : GapConductanceConstraint::GapConductanceConstraint(const InputParameters & parameters)
      32             :   : ADMortarConstraint(parameters),
      33          27 :     _k(getParam<Real>("k")),
      34          54 :     _min_gap(getParam<Real>("min_gap")),
      35          54 :     _disp_name(parameters.getVecMooseType("displacements")),
      36          27 :     _n_disp(_disp_name.size()),
      37          27 :     _disp_secondary(_n_disp),
      38          54 :     _disp_primary(_n_disp)
      39             : {
      40          63 :   for (unsigned int i = 0; i < _n_disp; ++i)
      41             :   {
      42          36 :     auto & disp_var = _subproblem.getStandardVariable(_tid, _disp_name[i]);
      43          36 :     _disp_secondary[i] = &disp_var.adSln();
      44          36 :     _disp_primary[i] = &disp_var.adSlnNeighbor();
      45             :   }
      46          27 : }
      47             : 
      48             : ADReal
      49       57860 : GapConductanceConstraint::computeQpResidual(Moose::MortarType mortar_type)
      50             : {
      51             :   using std::max;
      52             : 
      53       57860 :   switch (mortar_type)
      54             :   {
      55       23144 :     case Moose::MortarType::Primary:
      56       23144 :       return _lambda[_qp] * _test_primary[_i][_qp];
      57       23144 :     case Moose::MortarType::Secondary:
      58       46288 :       return -_lambda[_qp] * _test_secondary[_i][_qp];
      59       11572 :     case Moose::MortarType::Lower:
      60             :     {
      61             :       // we are creating an AD version of phys points primary and secondary here...
      62       11572 :       ADRealVectorValue ad_phys_points_primary = _phys_points_primary[_qp];
      63       11572 :       ADRealVectorValue ad_phys_points_secondary = _phys_points_secondary[_qp];
      64             : 
      65             :       // ...which uses the derivative vector of the primary and secondary displacements as
      66             :       // an approximation of the true phys points derivatives when the mesh is displacing
      67       11572 :       if (_displaced)
      68       13992 :         for (unsigned int i = 0; i < _n_disp; ++i)
      69             :         {
      70        9328 :           ad_phys_points_primary(i).derivatives() = (*_disp_primary[i])[_qp].derivatives();
      71        9328 :           ad_phys_points_secondary(i).derivatives() = (*_disp_secondary[i])[_qp].derivatives();
      72             :         }
      73             : 
      74       11572 :       auto l = max((ad_phys_points_primary - ad_phys_points_secondary) * _normals[_qp], _min_gap);
      75       46288 :       return (_lambda[_qp] - _k * (_u_primary[_qp] - _u_secondary[_qp]) / l) * _test[_i][_qp];
      76             :     }
      77             : 
      78           0 :     default:
      79           0 :       return 0;
      80             :   }
      81             : }

Generated by: LCOV version 1.14