https://mooseframework.inl.gov
GapConductanceStatefulConstraint.C
Go to the documentation of this file.
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 
11 
13 
16 {
18  params.addClassDescription(
19  "Computes the residual and Jacobian contributions for the 'Lagrange Multiplier' "
20  "implementation of the thermal contact problem. It pulls an auxiliary variable that acts as "
21  "an old material property recovered at the node using the nodal patch recovery capability.");
22  params.addRequiredParam<Real>("k", "Gap conductance.");
23  params.addCoupledVar(
24  "stateful_variable",
25  "The history variable whose old state we use for the constraint computation.");
26  params.addParam<Real>("min_gap",
27  1e-3,
28  "The minimum gap distance allowed. This helps with preventing the heat "
29  "flux from going to infinity as the gap approaches zero.");
30  params.addCoupledVar("displacements", "Displacement variables.");
31  return params;
32 }
33 
35  const InputParameters & parameters)
36  : ADMortarConstraint(parameters),
37  _k(getParam<Real>("k")),
38  _min_gap(getParam<Real>("min_gap")),
39  _disp_name(parameters.getVecMooseType("displacements")),
40  _n_disp(_disp_name.size()),
41  _disp_secondary(_n_disp),
42  _disp_primary(_n_disp),
43  _stress_old(isCoupled("stateful_variable") ? coupledValueOld("stateful_variable") : _zero),
44  _stress_neighbor_old(
45  isCoupled("stateful_variable") ? coupledNeighborValueOld("stateful_variable") : _zero)
46 {
47  for (unsigned int i = 0; i < _n_disp; ++i)
48  {
49  auto & disp_var = _subproblem.getStandardVariable(_tid, _disp_name[i]);
50  _disp_secondary[i] = &disp_var.adSln();
51  _disp_primary[i] = &disp_var.adSlnNeighbor();
52  }
53 }
54 
55 ADReal
57 {
58  switch (mortar_type)
59  {
61  return _lambda[_qp] * _test_primary[_i][_qp];
63  return -_lambda[_qp] * _test_secondary[_i][_qp];
65  {
66  // we are creating an AD version of phys points primary and secondary here...
67  ADRealVectorValue ad_phys_points_primary = _phys_points_primary[_qp];
68  ADRealVectorValue ad_phys_points_secondary = _phys_points_secondary[_qp];
69 
70  // ...which uses the derivative vector of the primary and secondary displacements as
71  // an approximation of the true phys points derivatives when the mesh is displacing
72  if (_displaced)
73  for (unsigned int i = 0; i < _n_disp; ++i)
74  {
75  ad_phys_points_primary(i).derivatives() = (*_disp_primary[i])[_qp].derivatives();
76  ad_phys_points_secondary(i).derivatives() = (*_disp_secondary[i])[_qp].derivatives();
77  }
78 
79  auto l =
80  std::max((ad_phys_points_primary - ad_phys_points_secondary) * _normals[_qp], _min_gap);
81  return (_lambda[_qp] - (_k + std::abs(_stress_old[_qp] + _stress_neighbor_old[_qp])) *
82  (_u_primary[_qp] - _u_secondary[_qp]) / l) *
83  _test[_i][_qp];
84  }
85 
86  default:
87  return 0;
88  }
89 }
const VariableTestValue & _test_secondary
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual ADReal computeQpResidual(Moose::MortarType mortar_type) override
Computes the residual for the LM equation, lambda = (k/l)*(T^(1) - PT^(2)).
const MooseArray< Point > & _phys_points_primary
const std::vector< std::string > _disp_name
Displacement variables.
const Real _k
Thermal conductivity of the gap medium (e.g. air).
unsigned int _i
const VariableValue & _stress_old
Old stress variable (possibly nodally recovered property) on secondary surface.
DualNumber< Real, DNDerivativeType, true > ADReal
const ADVariableValue & _lambda
void addRequiredParam(const std::string &name, const std::string &doc_string)
const VariableTestValue & _test
std::vector< Point > _normals
SubProblem & _subproblem
registerMooseObject("CombinedTestApp", GapConductanceStatefulConstraint)
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
const MooseArray< Point > & _phys_points_secondary
std::vector< const ADVariableValue * > _disp_primary
void addCoupledVar(const std::string &name, const std::string &doc_string)
const bool _displaced
const VariableValue & _stress_neighbor_old
Old stress variable (possibly nodally recovered property) on primary surface.
const Real _min_gap
Minimum gap distance allowed.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< const ADVariableValue * > _disp_secondary
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
GapConductanceStatefulConstraint(const InputParameters &parameters)
const ADVariableValue & _u_primary
const VariableTestValue & _test_primary
unsigned int _qp
const ADVariableValue & _u_secondary