<commit_before>#include "GapHeatTransfer.h"
#include "SystemBase.h"

Threads::spin_mutex slave_flux_mutex;

template<>
InputParameters validParams<GapHeatTransfer>()
{
  InputParameters params = validParams<IntegratedBC>();
  params.addRequiredCoupledVar("gap_distance", "Distance across the gap");
  params.addRequiredCoupledVar("gap_temp", "Temperature on the other side of the gap");
  params.addParam<Real>("gap_conductivity", 1.0, "The thermal conductivity of the gap material");
  params.addParam<Real>("min_gap", 1.0e-6, "A minimum gap size");
  params.addParam<Real>("max_gap", 1.0e6, "A maximum gap size");
  return params;
}

GapHeatTransfer::GapHeatTransfer(const std::string & name, InputParameters parameters)
  :IntegratedBC(name, parameters),
   _slave_flux(_sys.getVector("slave_flux")),
   _gap_distance(coupledValue("gap_distance")),
   _gap_temp(coupledValue("gap_temp")),
   _gap_conductivity(getParam<Real>("gap_conductivity")),
   _min_gap(getParam<Real>("min_gap")),
   _max_gap(getParam<Real>("max_gap"))
{
}


Real
GapHeatTransfer::computeQpResidual()
{
  Real h_gap = 0.0;
  Real grad_t = 0.0;
  
  h_gap = h_conduction() + h_contact() + h_radiation();
  grad_t = (_u[_qp] - _gap_temp[_qp]) * h_gap;

  // This is keeping track of this residual contribution so it can be used as the flux on the other side of the gap.
  {
    Threads::spin_mutex::scoped_lock lock(slave_flux_mutex);
    _slave_flux.add(_var.dofIndices()[_i], _JxW[_qp]*_phi[_i][_qp]*grad_t);
  }
  
  return _phi[_i][_qp]*grad_t;
}


Real
GapHeatTransfer::computeQpJacobian()
{
  Real h_gap = 0.0;
  Real grad_t = 0.0;
  Real dgrad_t = 0.0;

  h_gap = h_conduction() + h_contact() + h_radiation();
  grad_t = (_u[_qp] - _gap_temp[_qp]) * h_gap;
  dgrad_t = _phi[_j][_qp] * h_gap;

  // Check this: Should we be multiplying by phi twice?
  return _phi[_i][_qp]*dgrad_t;
}


Real
GapHeatTransfer::h_conduction()
{
  Real gap_L = gapLength();
 return gapK()/(gap_L + _min_gap);  
}


Real
GapHeatTransfer::h_contact()
{
  return 0.0;  
}


Real
GapHeatTransfer::h_radiation()
{
  return 0.0;  <commit_msg>remove unneeded comment<commit_after>#include "GapHeatTransfer.h"
#include "SystemBase.h"

Threads::spin_mutex slave_flux_mutex;

template<>
InputParameters validParams<GapHeatTransfer>()
{
  InputParameters params = validParams<IntegratedBC>();
  params.addRequiredCoupledVar("gap_distance", "Distance across the gap");
  params.addRequiredCoupledVar("gap_temp", "Temperature on the other side of the gap");
  params.addParam<Real>("gap_conductivity", 1.0, "The thermal conductivity of the gap material");
  params.addParam<Real>("min_gap", 1.0e-6, "A minimum gap size");
  params.addParam<Real>("max_gap", 1.0e6, "A maximum gap size");
  return params;
}

GapHeatTransfer::GapHeatTransfer(const std::string & name, InputParameters parameters)
  :IntegratedBC(name, parameters),
   _slave_flux(_sys.getVector("slave_flux")),
   _gap_distance(coupledValue("gap_distance")),
   _gap_temp(coupledValue("gap_temp")),
   _gap_conductivity(getParam<Real>("gap_conductivity")),
   _min_gap(getParam<Real>("min_gap")),
   _max_gap(getParam<Real>("max_gap"))
{
}


Real
GapHeatTransfer::computeQpResidual()
{
  Real h_gap = 0.0;
  Real grad_t = 0.0;
  
  h_gap = h_conduction() + h_contact() + h_radiation();
  grad_t = (_u[_qp] - _gap_temp[_qp]) * h_gap;

  // This is keeping track of this residual contribution so it can be used as the flux on the other side of the gap.
  {
    Threads::spin_mutex::scoped_lock lock(slave_flux_mutex);
    _slave_flux.add(_var.dofIndices()[_i], _JxW[_qp]*_phi[_i][_qp]*grad_t);
  }
  
  return _phi[_i][_qp]*grad_t;
}


Real
GapHeatTransfer::computeQpJacobian()
{
  Real h_gap = 0.0;
  Real grad_t = 0.0;
  Real dgrad_t = 0.0;

  h_gap = h_conduction() + h_contact() + h_radiation();
  grad_t = (_u[_qp] - _gap_temp[_qp]) * h_gap;
  dgrad_t = _phi[_j][_qp] * h_gap;

  return _phi[_i][_qp]*dgrad_t;
}


Real
GapHeatTransfer::h_conduction()
{
  Real gap_L = gapLength();
 return gapK()/(gap_L + _min_gap);  
}


Real
GapHeatTransfer::h_contact()
{
  return 0.0;  
}


Real
GapHeatTransfer::h_radiation()
{
  return 0.0;  
{'fraction_non_alphanumeric': 0.14478764478764478, 'fraction_numerical': 0.010617760617760617, 'mean_word_length': 5.32824427480916, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4254935', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1566, 'n_words': 305}