LCOV - code coverage report
Current view: top level - src/bcs - HeatStructure2DCouplerBCBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 24 25 96.0 %
Date: 2025-07-30 13:02:48 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         546 : HeatStructure2DCouplerBCBase::validParams()
      15             : {
      16         546 :   InputParameters params = ADIntegratedBC::validParams();
      17             : 
      18        1092 :   params.addRequiredParam<std::string>("coupled_variable",
      19             :                                        "The variable on the coupled heat structure boundary");
      20        1092 :   params.addRequiredParam<MeshAlignment *>("_mesh_alignment", "Mesh alignment object");
      21         546 :   params.addClassDescription(
      22             :       "Base class for heat flux boundary condition for coupling two heat structures");
      23         546 :   return params;
      24           0 : }
      25             : 
      26         294 : HeatStructure2DCouplerBCBase::HeatStructure2DCouplerBCBase(const InputParameters & parameters)
      27             :   : ADIntegratedBC(parameters),
      28             : 
      29         294 :     _coupled_variable_number(
      30         294 :         _subproblem.getVariable(_tid, getParam<std::string>("coupled_variable"), Moose::VAR_SOLVER)
      31             :             .number()),
      32         588 :     _mesh_alignment(*getParam<MeshAlignment *>("_mesh_alignment")),
      33             : 
      34         294 :     _nl_sys(_subproblem.systemBaseNonlinear(_sys.number())),
      35         588 :     _serialized_solution(_nl_sys.currentSolution())
      36             : {
      37         294 : }
      38             : 
      39             : ADReal
      40      384000 : HeatStructure2DCouplerBCBase::computeCoupledTemperature() const
      41             : {
      42      384000 :   ADReal T_coupled = 0;
      43     1920000 :   for (const auto j : _current_elem->node_index_range())
      44             :   {
      45     1536000 :     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     1536000 :     if (_mesh_alignment.hasCoupledNodeID(node_id))
      49             :     {
      50      768000 :       const auto neighbor_node_id = _mesh_alignment.getCoupledNodeID(node_id);
      51      768000 :       const Node & neighbor_node = _mesh.nodeRef(neighbor_node_id);
      52             :       const auto dof_number =
      53      768000 :           neighbor_node.dof_number(_nl_sys.number(), _coupled_variable_number, 0);
      54      768000 :       ADReal T_node = (*_serialized_solution)(dof_number);
      55             :       Moose::derivInsert(T_node.derivatives(), dof_number, 1.0);
      56     1536000 :       T_coupled += T_node * _test[j][_qp];
      57             :     }
      58             :   }
      59             : 
      60      384000 :   return T_coupled;
      61             : }

Generated by: LCOV version 1.14