www.mooseframework.org
GapHeatTransfer.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "GapHeatTransfer.h"
11 
12 // MOOSE includes
13 #include "AddVariableAction.h"
14 #include "Assembly.h"
15 #include "MooseMesh.h"
16 #include "MooseVariable.h"
17 #include "PenetrationLocator.h"
18 #include "SystemBase.h"
19 
20 #include "libmesh/string_to_enum.h"
21 
22 registerMooseObject("HeatConductionApp", GapHeatTransfer);
23 
25 
26 InputParameters
28 {
29  InputParameters params = IntegratedBC::validParams();
30  params.addClassDescription("Transfers heat across a gap between two "
31  "surfaces dependent on the gap geometry specified.");
32  params.addParam<std::string>(
33  "appended_property_name", "", "Name appended to material properties to make them unique");
34 
35  // Common
36  params.addParam<Real>("min_gap", 1.0e-6, "A minimum gap size");
37  params.addParam<Real>("max_gap", 1.0e6, "A maximum gap size");
38  params.addRangeCheckedParam<unsigned int>(
39  "min_gap_order", 0, "min_gap_order<=1", "Order of the Taylor expansion below min_gap");
40 
41  // Deprecated parameter
42  MooseEnum coord_types("default XYZ cyl", "default");
43  params.addDeprecatedParam<MooseEnum>(
44  "coord_type",
45  coord_types,
46  "Gap calculation type (default or XYZ).",
47  "The functionality of this parameter is replaced by 'gap_geometry_type'.");
48 
49  MooseEnum gap_geom_types("PLATE CYLINDER SPHERE");
50  params.addParam<MooseEnum>("gap_geometry_type",
51  gap_geom_types,
52  "Gap calculation type. Choices are: " + gap_geom_types.getRawNames());
53 
54  params.addParam<RealVectorValue>("cylinder_axis_point_1",
55  "Start point for line defining cylindrical axis");
56  params.addParam<RealVectorValue>("cylinder_axis_point_2",
57  "End point for line defining cylindrical axis");
58  params.addParam<RealVectorValue>("sphere_origin", "Origin for sphere geometry");
59 
60  // Quadrature based
61  params.addParam<bool>("quadrature",
62  false,
63  "Whether or not to do Quadrature point based gap heat "
64  "transfer. If this is true then gap_distance and "
65  "gap_temp should NOT be provided (and will be "
66  "ignored) however paired_boundary IS then required.");
67  params.addParam<BoundaryName>("paired_boundary", "The boundary to be penetrated");
68 
69  MooseEnum orders(AddVariableAction::getNonlinearVariableOrders());
70  params.addParam<MooseEnum>("order", orders, "The finite element order");
71 
72  params.addParam<bool>(
73  "warnings", false, "Whether to output warning messages concerning nodes not being found");
74 
75  params.addCoupledVar("disp_x", "The x displacement");
76  params.addCoupledVar("disp_y", "The y displacement");
77  params.addCoupledVar("disp_z", "The z displacement");
78 
79  params.addCoupledVar(
80  "displacements",
81  "The displacements appropriate for the simulation geometry and coordinate system");
82 
83  // Node based options
84  params.addCoupledVar("gap_distance", "Distance across the gap");
85  params.addCoupledVar("gap_temp", "Temperature on the other side of the gap");
86 
87  return params;
88 }
89 
90 GapHeatTransfer::GapHeatTransfer(const InputParameters & parameters)
91  : IntegratedBC(parameters),
92  _gap_geometry_type(declareRestartableData<GapConductance::GAP_GEOMETRY>("gap_geometry_type",
93  GapConductance::PLATE)),
94  _quadrature(getParam<bool>("quadrature")),
95  _slave_flux(!_quadrature ? &_sys.getVector("slave_flux") : NULL),
96  _gap_conductance(getMaterialProperty<Real>("gap_conductance" +
97  getParam<std::string>("appended_property_name"))),
98  _gap_conductance_dT(getMaterialProperty<Real>(
99  "gap_conductance" + getParam<std::string>("appended_property_name") + "_dT")),
100  _min_gap(getParam<Real>("min_gap")),
101  _min_gap_order(getParam<unsigned int>("min_gap_order")),
102  _max_gap(getParam<Real>("max_gap")),
103  _gap_temp(0),
104  _gap_distance(std::numeric_limits<Real>::max()),
105  _edge_multiplier(1.0),
106  _has_info(false),
107  _disp_vars(3, libMesh::invalid_uint),
108  _gap_distance_value(_quadrature ? _zero : coupledValue("gap_distance")),
109  _gap_temp_value(_quadrature ? _zero : coupledValue("gap_temp")),
110  _penetration_locator(
111  !_quadrature ? NULL
112  : &getQuadraturePenetrationLocator(
113  parameters.get<BoundaryName>("paired_boundary"),
114  getParam<std::vector<BoundaryName>>("boundary")[0],
115  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
116  _warnings(getParam<bool>("warnings")),
117  _p1(declareRestartableData<Point>("cylinder_axis_point_1", Point(0, 1, 0))),
118  _p2(declareRestartableData<Point>("cylinder_axis_point_2", Point(0, 0, 0)))
119 {
120  if (isParamValid("displacements"))
121  {
122  // modern parameter scheme for displacements
123  for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
124  _disp_vars[i] = coupled("displacements", i);
125  }
126  else
127  {
128  // Legacy parameter scheme for displacements
129  if (isParamValid("disp_x"))
130  _disp_vars[0] = coupled("disp_x");
131  if (isParamValid("disp_y"))
132  _disp_vars[1] = coupled("disp_y");
133  if (isParamValid("disp_z"))
134  _disp_vars[2] = coupled("disp_z");
135 
136  // TODO: these are only used in one Bison test. Deprecate soon!
137  }
138 
139  if (_quadrature)
140  {
141  if (!parameters.isParamValid("paired_boundary"))
142  mooseError(std::string("No 'paired_boundary' provided for ") + _name);
143  }
144  else
145  {
146  if (!isCoupled("gap_distance"))
147  mooseError(std::string("No 'gap_distance' provided for ") + _name);
148 
149  if (!isCoupled("gap_temp"))
150  mooseError(std::string("No 'gap_temp' provided for ") + _name);
151  }
152 }
153 
154 void
156 {
158  _assembly.coordSystem(),
159  _fe_problem.getAxisymmetricRadialCoord(),
161  _p1,
162  _p2);
163 }
164 
165 Real
167 {
169 
170  if (!_has_info)
171  return 0.0;
172 
173  Real grad_t = (_u[_qp] - _gap_temp) * _edge_multiplier * _gap_conductance[_qp];
174 
175  // This is keeping track of this residual contribution so it can be used as the flux on the other
176  // side of the gap.
177  if (!_quadrature)
178  {
179  Threads::spin_mutex::scoped_lock lock(Threads::spin_mutex);
180  const Real slave_flux = computeSlaveFluxContribution(grad_t);
181  _slave_flux->add(_var.dofIndices()[_i], slave_flux);
182  }
183 
184  return _test[_i][_qp] * grad_t;
185 }
186 
187 Real
189 {
190  return _coord[_qp] * _JxW[_qp] * _test[_i][_qp] * grad_t;
191 }
192 
193 Real
195 {
197 
198  if (!_has_info)
199  return 0.0;
200 
201  return _test[_i][_qp] *
202  ((_u[_qp] - _gap_temp) * _edge_multiplier * _gap_conductance_dT[_qp] +
204  _phi[_j][_qp];
205 }
206 
207 Real
209 {
211 
212  if (!_has_info)
213  return 0.0;
214 
215  unsigned int coupled_component;
216  bool active = false;
217  for (coupled_component = 0; coupled_component < _disp_vars.size(); ++coupled_component)
218  if (jvar == _disp_vars[coupled_component])
219  {
220  active = true;
221  break;
222  }
223 
224  Real dRdx = 0.0;
225  if (active)
226  {
227  // Compute dR/du_[xyz]
228  // Residual is based on
229  // h_gap = h_conduction() + h_contact() + h_radiation();
230  // grad_t = (_u[_qp] - _gap_temp) * h_gap;
231  // So we need
232  // (_u[_qp] - _gap_temp) * (dh_gap/du_[xyz]);
233  // Assuming dh_contact/du_[xyz] = dh_radiation/du_[xyz] = 0,
234  // we need dh_conduction/du_[xyz]
235  // Given
236  // h_conduction = gapK / gapLength, then
237  // dh_conduction/du_[xyz] = -gapK/gapLength^2 * dgapLength/du_[xyz]
238  // Given
239  // gapLength = ((u_x-m_x)^2+(u_y-m_y)^2+(u_z-m_z)^2)^1/2
240  // where m_[xyz] is the master coordinate, then
241  // dGapLength/du_[xyz] = 1/2*((u_x-m_x)^2+(u_y-m_y)^2+(u_z-m_z)^2)^(-1/2)*2*(u_[xyz]-m_[xyz])
242  // = (u_[xyz]-m_[xyz])/gapLength
243  // This is the normal vector.
244 
245  const Real gapL = gapLength();
246 
247  // THIS IS NOT THE NORMAL WE NEED.
248  // WE NEED THE NORMAL FROM THE CONSTRAINT, THE NORMAL FROM THE
249  // MASTER SURFACE. HOWEVER, THIS IS TRICKY SINCE THE NORMAL
250  // FROM THE MASTER SURFACE WAS COMPUTED FOR A POINT ASSOCIATED
251  // WITH A SLAVE NODE. NOW WE ARE AT A SLAVE INTEGRATION POINT.
252  //
253  // HOW DO WE GET THE NORMAL WE NEED?
254  //
255  // Until we have the normal we need,
256  // we'll hope that the one we have is close to the negative of the one we need.
257  const Point & normal(_normals[_qp]);
258 
259  const Real dgap = dgapLength(-normal(coupled_component));
260  dRdx = -(_u[_qp] - _gap_temp) * _edge_multiplier * _gap_conductance[_qp] *
262  }
263  return _test[_i][_qp] * dRdx * _phi[_j][_qp];
264 }
265 
266 Real
268 {
269  if (_has_info)
271 
272  return 1.0;
273 }
274 
275 Real
276 GapHeatTransfer::dgapLength(Real normalComponent) const
277 {
278  const Real gap_L = gapLength();
279  Real dgap = 0.0;
280 
281  if (_min_gap <= gap_L && gap_L <= _max_gap)
282  dgap = normalComponent;
283 
284  return dgap;
285 }
286 
287 void
289 {
290  if (!_quadrature)
291  {
292  _has_info = true;
293  _gap_temp = _gap_temp_value[_qp];
295  }
296  else
297  {
298  Node * qnode = _mesh.getQuadratureNode(_current_elem, _current_side, _qp);
299  PenetrationInfo * pinfo = _penetration_locator->_penetration_info[qnode->id()];
300 
301  _gap_temp = 0.0;
302  _gap_distance = std::numeric_limits<Real>::max();
303  _has_info = false;
304  _edge_multiplier = 1.0;
305 
306  if (pinfo)
307  {
308  _gap_distance = pinfo->_distance;
309  _has_info = true;
310 
311  const Elem * slave_side = pinfo->_side;
312  std::vector<std::vector<Real>> & slave_side_phi = pinfo->_side_phi;
313  _gap_temp = _variable->getValue(slave_side, slave_side_phi);
314 
315  Real tangential_tolerance = _penetration_locator->getTangentialTolerance();
316  if (tangential_tolerance != 0.0)
317  {
318  _edge_multiplier = 1.0 - pinfo->_tangential_distance / tangential_tolerance;
319  if (_edge_multiplier < 0.0)
320  _edge_multiplier = 0.0;
321  }
322  }
323  else
324  {
325  if (_warnings)
326  mooseWarning("No gap value information found for node ",
327  qnode->id(),
328  " on processor ",
329  processor_id());
330  }
331  }
332 
334  _gap_geometry_type, _q_point[_qp], _p1, _p2, _gap_distance, _normals[_qp], _r1, _r2, _radius);
335 }
GapHeatTransfer::_quadrature
const bool _quadrature
Definition: GapHeatTransfer.h:45
GapHeatTransfer::_gap_conductance_dT
const MaterialProperty< Real > & _gap_conductance_dT
Definition: GapHeatTransfer.h:50
GapHeatTransfer::initialSetup
virtual void initialSetup() override
Definition: GapHeatTransfer.C:155
GapHeatTransfer::_has_info
bool _has_info
Definition: GapHeatTransfer.h:68
GapHeatTransfer::dgapLength
virtual Real dgapLength(Real normalComponent) const
Definition: GapHeatTransfer.C:276
GapHeatTransfer::computeQpResidual
virtual Real computeQpResidual() override
Definition: GapHeatTransfer.C:166
GapHeatTransfer::_disp_vars
std::vector< unsigned int > _disp_vars
Definition: GapHeatTransfer.h:70
GapHeatTransfer::_min_gap
const Real _min_gap
Definition: GapHeatTransfer.h:52
GapHeatTransfer::_gap_geometry_type
GapConductance::GAP_GEOMETRY & _gap_geometry_type
Definition: GapHeatTransfer.h:43
libMesh
Definition: RANFSNormalMechanicalContact.h:24
GapConductance::gapAttenuation
static Real gapAttenuation(Real adjusted_length, Real min_gap, unsigned int min_gap_order)
Definition: GapConductance.C:287
GapHeatTransfer
Generic gap heat transfer model, with h_gap = h_conduction + h_contact + h_radiation.
Definition: GapHeatTransfer.h:24
GapHeatTransfer::_slave_flux
NumericVector< Number > * _slave_flux
Definition: GapHeatTransfer.h:47
GapConductance::gapLength
static Real gapLength(const GAP_GEOMETRY &gap_geom, Real radius, Real r1, Real r2, Real max_gap)
Definition: GapConductance.C:361
defineLegacyParams
defineLegacyParams(GapHeatTransfer)
GapConductance::setGapGeometryParameters
static void setGapGeometryParameters(const InputParameters &params, const Moose::CoordinateSystemType coord_sys, unsigned int axisymmetric_radial_coord, GAP_GEOMETRY &gap_geometry_type, Point &p1, Point &p2)
Definition: GapConductance.C:183
GapHeatTransfer::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned jvar) override
Definition: GapHeatTransfer.C:208
GapHeatTransfer::_r1
Real _r1
Definition: GapHeatTransfer.h:59
GapHeatTransfer::_p1
Point & _p1
Definition: GapHeatTransfer.h:78
GapHeatTransfer::_gap_distance_value
const VariableValue & _gap_distance_value
Definition: GapHeatTransfer.h:72
GapHeatTransfer::_gap_temp
Real _gap_temp
Definition: GapHeatTransfer.h:56
GapHeatTransfer::_max_gap
const Real _max_gap
Definition: GapHeatTransfer.h:54
GapHeatTransfer.h
GapHeatTransfer::_radius
Real _radius
Definition: GapHeatTransfer.h:58
GapHeatTransfer::_r2
Real _r2
Definition: GapHeatTransfer.h:60
GapHeatTransfer::_p2
Point & _p2
Definition: GapHeatTransfer.h:79
validParams
InputParameters validParams()
GapHeatTransfer::_gap_temp_value
const VariableValue & _gap_temp_value
Definition: GapHeatTransfer.h:73
GapHeatTransfer::GapHeatTransfer
GapHeatTransfer(const InputParameters &parameters)
Definition: GapHeatTransfer.C:90
GapHeatTransfer::computeQpJacobian
virtual Real computeQpJacobian() override
Definition: GapHeatTransfer.C:194
GapHeatTransfer::_min_gap_order
const unsigned int _min_gap_order
Definition: GapHeatTransfer.h:53
GapHeatTransfer::_warnings
const bool _warnings
Definition: GapHeatTransfer.h:76
GapHeatTransfer::_gap_distance
Real _gap_distance
Definition: GapHeatTransfer.h:57
GapHeatTransfer::computeGapValues
virtual void computeGapValues()
Definition: GapHeatTransfer.C:288
GapHeatTransfer::validParams
static InputParameters validParams()
Definition: GapHeatTransfer.C:27
GapHeatTransfer::_edge_multiplier
Real _edge_multiplier
This is a factor that is used to gradually taper down the conductance if the contact point is off the...
Definition: GapHeatTransfer.h:66
GapHeatTransfer::_gap_conductance
const MaterialProperty< Real > & _gap_conductance
Definition: GapHeatTransfer.h:49
GapHeatTransfer::gapLength
virtual Real gapLength() const
Definition: GapHeatTransfer.C:267
registerMooseObject
registerMooseObject("HeatConductionApp", GapHeatTransfer)
GapHeatTransfer::computeSlaveFluxContribution
virtual Real computeSlaveFluxContribution(Real grad_t)
Definition: GapHeatTransfer.C:188
GapConductance::computeGapRadii
static void computeGapRadii(const GAP_GEOMETRY gap_geometry_type, const Point &current_point, const Point &p1, const Point &p2, const Real &gap_distance, const Point &current_normal, Real &r1, Real &r2, Real &radius)
Definition: GapConductance.C:462
GapHeatTransfer::_penetration_locator
PenetrationLocator * _penetration_locator
Definition: GapHeatTransfer.h:75
GapConductance
Generic gap heat transfer model, with h_gap = h_conduction + h_contact + h_radiation.
Definition: GapConductance.h:17