LCOV - code coverage report
Current view: top level - src/bcs - HeatStructure2DCouplerBCBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 24 25 96.0 %
Date: 2026-05-29 20:41:18 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "HeatStructure2DCouplerBCBase.h"
      11             : #include "MeshAlignment.h"
      12             : 
      13             : InputParameters
      14         238 : HeatStructure2DCouplerBCBase::validParams()
      15             : {
      16         238 :   InputParameters params = ADIntegratedBC::validParams();
      17             : 
      18         476 :   params.addRequiredParam<std::string>("coupled_variable",
      19             :                                        "The variable on the coupled heat structure boundary");
      20         476 :   params.addRequiredParam<MeshAlignment *>("_mesh_alignment", "Mesh alignment object");
      21         238 :   params.addClassDescription(
      22             :       "Base class for heat flux boundary condition for coupling two heat structures");
      23         238 :   return params;
      24           0 : }
      25             : 
      26         126 : HeatStructure2DCouplerBCBase::HeatStructure2DCouplerBCBase(const InputParameters & parameters)
      27             :   : ADIntegratedBC(parameters),
      28             : 
      29         126 :     _coupled_variable_number(
      30         126 :         _subproblem.getVariable(_tid, getParam<std::string>("coupled_variable"), Moose::VAR_SOLVER)
      31             :             .number()),
      32         252 :     _mesh_alignment(*getParam<MeshAlignment *>("_mesh_alignment")),
      33             : 
      34         126 :     _nl_sys(_subproblem.systemBaseNonlinear(_sys.number())),
      35         252 :     _serialized_solution(_nl_sys.currentSolution())
      36             : {
      37         126 : }
      38             : 
      39             : ADReal
      40      240000 : HeatStructure2DCouplerBCBase::computeCoupledTemperature() const
      41             : {
      42      240000 :   ADReal T_coupled = 0;
      43     1200000 :   for (const auto j : _current_elem->node_index_range())
      44             :   {
      45      960000 :     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      960000 :     if (_mesh_alignment.hasCoupledNodeID(node_id))
      49             :     {
      50      480000 :       const auto neighbor_node_id = _mesh_alignment.getCoupledNodeID(node_id);
      51      480000 :       const Node & neighbor_node = _mesh.nodeRef(neighbor_node_id);
      52             :       const auto dof_number =
      53      480000 :           neighbor_node.dof_number(_nl_sys.number(), _coupled_variable_number, 0);
      54      480000 :       ADReal T_node = (*_serialized_solution)(dof_number);
      55             :       Moose::derivInsert(T_node.derivatives(), dof_number, 1.0);
      56      960000 :       T_coupled += T_node * _test[j][_qp];
      57             :     }
      58             :   }
      59             : 
      60      240000 :   return T_coupled;
      61             : }

Generated by: LCOV version 1.14