https://mooseframework.inl.gov
HeatStructure2DCouplerBCBase.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 #include "MeshAlignment.h"
12 
15 {
17 
18  params.addRequiredParam<std::string>("coupled_variable",
19  "The variable on the coupled heat structure boundary");
20  params.addRequiredParam<MeshAlignment *>("_mesh_alignment", "Mesh alignment object");
21  params.addClassDescription(
22  "Base class for heat flux boundary condition for coupling two heat structures");
23  return params;
24 }
25 
27  : ADIntegratedBC(parameters),
28 
29  _coupled_variable_number(
30  _subproblem.getVariable(_tid, getParam<std::string>("coupled_variable"), Moose::VAR_SOLVER)
31  .number()),
32  _mesh_alignment(*getParam<MeshAlignment *>("_mesh_alignment")),
33 
34  _nl_sys(_subproblem.systemBaseNonlinear(_sys.number())),
35  _serialized_solution(_nl_sys.currentSolution())
36 {
37 }
38 
39 ADReal
41 {
42  ADReal T_coupled = 0;
43  for (const auto j : _current_elem->node_index_range())
44  {
45  const auto node_id = (_current_elem->node_ref(j)).id();
46  // This check is because we're looping over all of the nodes of the current
47  // element, not just those on the boundary; we must exclude the interior nodes.
48  if (_mesh_alignment.hasCoupledNodeID(node_id))
49  {
50  const auto neighbor_node_id = _mesh_alignment.getCoupledNodeID(node_id);
51  const Node & neighbor_node = _mesh.nodeRef(neighbor_node_id);
52  const auto dof_number =
53  neighbor_node.dof_number(_nl_sys.number(), _coupled_variable_number, 0);
54  ADReal T_node = (*_serialized_solution)(dof_number);
55  Moose::derivInsert(T_node.derivatives(), dof_number, 1.0);
56  T_coupled += T_node * _test[j][_qp];
57  }
58  }
59 
60  return T_coupled;
61 }
VAR_SOLVER
const Elem *const & _current_elem
bool hasCoupledNodeID(const dof_id_type &node_id) const
Returns true if the node ID has a coupled node ID.
HeatStructure2DCouplerBCBase(const InputParameters &parameters)
Builds mapping between two aligned subdomains/boundaries.
Definition: MeshAlignment.h:24
DualNumber< Real, DNDerivativeType, true > ADReal
static InputParameters validParams()
virtual const Node & nodeRef(const dof_id_type i) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
const dof_id_type & getCoupledNodeID(const dof_id_type &node_id) const
Gets the coupled node ID for a given node ID.
unsigned int number() const
ADReal computeCoupledTemperature() const
Computes the coupled neighbor temperature.
const unsigned int _coupled_variable_number
Variable number of the variable to transfer.
const ADTemplateVariableTestValue< T > & _test
void addClassDescription(const std::string &doc_string)
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const SystemBase & _nl_sys
Nonlinear system.
MeshAlignment & _mesh_alignment
Mesh alignment object.