LCOV - code coverage report
Current view: top level - src/bcs - HeatFluxBaseBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 0 46 0.0 %
Date: 2025-07-30 13:02:48 Functions: 0 5 0.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 "HeatFluxBaseBC.h"
      11             : #include "HeatFluxFromHeatStructureBaseUserObject.h"
      12             : #include "THMIndicesVACE.h"
      13             : #include "Assembly.h"
      14             : #include "NonlinearSystemBase.h"
      15             : 
      16             : InputParameters
      17           0 : HeatFluxBaseBC::validParams()
      18             : {
      19           0 :   InputParameters params = IntegratedBC::validParams();
      20           0 :   params.addRequiredParam<UserObjectName>(
      21             :       "q_uo", "The name of the user object that computes the heat flux");
      22           0 :   params.addRequiredParam<Real>("P_hs_unit", "Perimeter of a single unit of heat structure");
      23           0 :   params.addRequiredParam<unsigned int>("n_unit", "Number of units of heat structure");
      24           0 :   params.addRequiredParam<bool>("hs_coord_system_is_cylindrical",
      25             :                                 "Is the heat structure coordinate system cylindrical?");
      26           0 :   params.addClassDescription("Base class for heat flux boundary conditions");
      27           0 :   return params;
      28           0 : }
      29             : 
      30           0 : HeatFluxBaseBC::HeatFluxBaseBC(const InputParameters & parameters)
      31             :   : IntegratedBC(parameters),
      32           0 :     _phi_neighbor(_assembly.phiNeighbor(_var)),
      33           0 :     _q_uo(getUserObject<HeatFluxFromHeatStructureBaseUserObject>("q_uo")),
      34           0 :     _P_hs_unit(getParam<Real>("P_hs_unit")),
      35           0 :     _n_unit(getParam<unsigned int>("n_unit")),
      36           0 :     _hs_coord_system_is_cylindrical(getParam<bool>("hs_coord_system_is_cylindrical")),
      37           0 :     _hs_coord(_hs_coord_system_is_cylindrical ? _P_hs_unit : 1.0),
      38           0 :     _hs_scale(-_hs_coord / (_n_unit * _P_hs_unit))
      39             : {
      40           0 : }
      41             : 
      42             : void
      43           0 : HeatFluxBaseBC::initialSetup()
      44             : {
      45           0 :   _off_diag_var_nums = getOffDiagVariableNumbers();
      46           0 : }
      47             : 
      48             : void
      49           0 : HeatFluxBaseBC::computeJacobian()
      50             : {
      51           0 :   IntegratedBC::computeJacobian();
      52           0 : }
      53             : 
      54             : void
      55           0 : HeatFluxBaseBC::computeOffDiagJacobian(const unsigned int jvar_num)
      56             : {
      57           0 :   IntegratedBC::computeOffDiagJacobian(jvar_num);
      58             : 
      59           0 :   if (jvar_num == _var.number())
      60             :   {
      61             :     // when doing the diagonal part, also take care of the off-diag jacobian
      62             :     // wrt the heat structure side
      63           0 :     std::vector<dof_id_type> idofs = _var.dofIndices();
      64             : 
      65           0 :     const dof_id_type & pipe_elem_id = _q_uo.getNearestElem(_current_elem->id());
      66           0 :     const Elem * neighbor = _mesh.elemPtr(pipe_elem_id);
      67             : 
      68           0 :     _assembly.setCurrentNeighborSubdomainID(neighbor->subdomain_id());
      69           0 :     _assembly.reinitNeighborAtPhysical(neighbor, _q_point.stdVector());
      70             : 
      71           0 :     for (std::size_t i = 0; i < _off_diag_var_nums.size(); i++)
      72             :     {
      73           0 :       unsigned int jvar_num = _off_diag_var_nums[i];
      74             :       MooseVariableFEBase & jvar =
      75           0 :           _fe_problem.getNonlinearSystemBase(_sys.number()).getVariable(_tid, jvar_num);
      76           0 :       jvar.prepareNeighbor();
      77           0 :       _assembly.copyNeighborShapes(jvar_num);
      78             : 
      79           0 :       auto & jdofs = jvar.dofIndicesNeighbor();
      80             : 
      81           0 :       DenseMatrix<Number> Ke(_test.size(), jvar.phiNeighborSize());
      82           0 :       for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      83           0 :         for (_i = 0; _i < _test.size(); _i++)
      84           0 :           for (_j = 0; _j < jvar.phiNeighborSize(); _j++)
      85           0 :             Ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobianNeighbor(jvar_num);
      86             : 
      87           0 :       addJacobian(_assembly, Ke, idofs, jdofs, _var.scalingFactor());
      88           0 :     }
      89             :   }
      90           0 : }

Generated by: LCOV version 1.14