https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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");
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
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.
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}
DualNumber< Real, DNDerivativeType, true > ADReal
static InputParameters validParams()
const ADTemplateVariableTestValue< T > & _test
const SystemBase & _nl_sys
Nonlinear system.
ADReal computeCoupledTemperature() const
Computes the coupled neighbor temperature.
const unsigned int _coupled_variable_number
Variable number of the variable to transfer.
MeshAlignment & _mesh_alignment
Mesh alignment object.
HeatStructure2DCouplerBCBase(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int _qp
const Elem *const & _current_elem
Builds mapping between two aligned subdomains/boundaries.
bool hasCoupledNodeID(const dof_id_type &node_id) const
Returns true if the node ID has a coupled node ID.
const dof_id_type & getCoupledNodeID(const dof_id_type &node_id) const
Gets the coupled node ID for a given node ID.
virtual const Node & nodeRef(const dof_id_type i) const
unsigned int number() const
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)