LCOV - code coverage report
Current view: top level - src/components - HeatTransferFromHeatStructure1Phase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 92 93 98.9 %
Date: 2025-07-30 13:02:48 Functions: 8 8 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 "HeatTransferFromHeatStructure1Phase.h"
      11             : #include "FlowChannel1PhaseBase.h"
      12             : #include "HeatStructureBase.h"
      13             : #include "HeatStructureCylindricalBase.h"
      14             : #include "FlowModelSinglePhase.h"
      15             : #include "THMMesh.h"
      16             : #include "MooseUtils.h"
      17             : 
      18             : registerMooseObject("ThermalHydraulicsApp", HeatTransferFromHeatStructure1Phase);
      19             : 
      20             : InputParameters
      21         604 : HeatTransferFromHeatStructure1Phase::validParams()
      22             : {
      23         604 :   InputParameters params = HeatTransferFromTemperature1Phase::validParams();
      24         604 :   params += HSBoundaryInterface::validParams();
      25             : 
      26        1208 :   params.addParam<MooseFunctorName>("scale", 1.0, "Functor by which to scale the heat flux");
      27             : 
      28         604 :   params.addClassDescription("Connects a 1-phase flow channel and a heat structure");
      29             : 
      30         604 :   return params;
      31           0 : }
      32             : 
      33         302 : HeatTransferFromHeatStructure1Phase::HeatTransferFromHeatStructure1Phase(
      34         302 :     const InputParameters & parameters)
      35             :   : HeatTransferFromTemperature1Phase(parameters),
      36             :     HSBoundaryInterface(this),
      37         302 :     _mesh_alignment(constMesh(), true)
      38             : {
      39         302 : }
      40             : 
      41             : const libMesh::FEType &
      42         288 : HeatTransferFromHeatStructure1Phase::getFEType()
      43             : {
      44         288 :   return HeatConductionModel::feType();
      45             : }
      46             : 
      47             : void
      48         302 : HeatTransferFromHeatStructure1Phase::setupMesh()
      49             : {
      50         302 :   if (hasComponentByName<HeatStructureBase>(_hs_name) &&
      51         300 :       hasComponentByName<FlowChannel1PhaseBase>(_flow_channel_name))
      52             :   {
      53             :     const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
      54             :     const FlowChannel1PhaseBase & flow_channel =
      55             :         getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
      56             : 
      57         298 :     if (!HSBoundaryIsValid(this))
      58           6 :       return;
      59             : 
      60         296 :     const auto hs_boundary = getHSBoundaryName(this);
      61             : 
      62         296 :     _mesh_alignment.initialize(flow_channel.getElementIDs(), hs.getBoundaryInfo(hs_boundary));
      63             : 
      64         296 :     if (!_mesh_alignment.meshesAreAligned())
      65             :     {
      66           4 :       logError("The centers of the elements of flow channel '",
      67             :                _flow_channel_name,
      68             :                "' do not align with the centers of the specified heat structure side.");
      69             :       return;
      70             :     }
      71             : 
      72        4796 :     for (const auto & elem_id : _mesh_alignment.getPrimaryElemIDs())
      73             :     {
      74        4504 :       if (_mesh_alignment.hasCoupledElemID(elem_id))
      75        4504 :         getTHMProblem().augmentSparsity(elem_id, _mesh_alignment.getCoupledElemID(elem_id));
      76             :     }
      77             :   }
      78             : }
      79             : 
      80             : void
      81         282 : HeatTransferFromHeatStructure1Phase::check() const
      82             : {
      83         282 :   HeatTransferFromTemperature1Phase::check();
      84         282 :   HSBoundaryInterface::check(this);
      85         282 : }
      86             : 
      87             : void
      88         288 : HeatTransferFromHeatStructure1Phase::addVariables()
      89             : {
      90         288 :   HeatTransferFromTemperature1Phase::addVariables();
      91             : 
      92             :   // wall temperature initial condition
      93         288 :   if (!getTHMProblem().hasInitialConditionsFromFile() && !_app.isRestarting())
      94             :   {
      95         280 :     const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
      96         560 :     getTHMProblem().addFunctionIC(_T_wall_name, hs.getInitialT(), _flow_channel_subdomains);
      97             :   }
      98         288 : }
      99             : 
     100             : void
     101         288 : HeatTransferFromHeatStructure1Phase::addMooseObjects()
     102             : {
     103         288 :   HeatTransferFromTemperature1Phase::addMooseObjects();
     104             : 
     105         288 :   ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum());
     106        1152 :   execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
     107             : 
     108         288 :   const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
     109         288 :   const bool is_cylindrical = dynamic_cast<const HeatStructureCylindricalBase *>(&hs) != nullptr;
     110             :   const FlowChannel1PhaseBase & flow_channel =
     111         288 :       getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
     112             : 
     113         576 :   const UserObjectName heat_flux_uo_name = genName(name(), "heat_flux_uo");
     114             :   {
     115         288 :     const std::string class_name = "ADHeatFluxFromHeatStructure3EqnUserObject";
     116         288 :     InputParameters params = _factory.getValidParams(class_name);
     117         288 :     params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
     118         288 :     params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
     119        1152 :     params.set<MaterialPropertyName>("T_wall") = _T_wall_name + "_coupled";
     120         864 :     params.set<std::vector<VariableName>>("P_hf") = {_P_hf_name};
     121         576 :     params.set<MaterialPropertyName>("Hw") = _Hw_1phase_name;
     122         576 :     params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE;
     123         864 :     params.set<MooseFunctorName>("scale") = getParam<MooseFunctorName>("scale");
     124         288 :     params.set<ExecFlagEnum>("execute_on") = execute_on;
     125         288 :     getTHMProblem().addUserObject(class_name, heat_flux_uo_name, params);
     126         288 :   }
     127             : 
     128             :   {
     129         288 :     const std::string class_name = "ADOneD3EqnEnergyHeatFlux";
     130         288 :     InputParameters params = _factory.getValidParams(class_name);
     131         576 :     params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
     132         576 :     params.set<NonlinearVariableName>("variable") = FlowModelSinglePhase::RHOEA;
     133         288 :     params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
     134         576 :     getTHMProblem().addKernel(class_name, genName(name(), "heat_flux_kernel"), params);
     135         288 :   }
     136             : 
     137             :   {
     138         288 :     const std::string class_name = "ADHeatFlux3EqnBC";
     139         288 :     InputParameters params = _factory.getValidParams(class_name);
     140         864 :     params.set<std::vector<BoundaryName>>("boundary") = {getHSBoundaryName(this)};
     141         576 :     params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
     142         288 :     params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
     143         288 :     params.set<Real>("P_hs_unit") = hs.getUnitPerimeter(getHSExternalBoundaryType(this));
     144         288 :     params.set<unsigned int>("n_unit") = hs.getNumberOfUnits();
     145         288 :     params.set<bool>("hs_coord_system_is_cylindrical") = is_cylindrical;
     146         576 :     getTHMProblem().addBoundaryCondition(class_name, genName(name(), "heat_flux_bc"), params);
     147         288 :   }
     148             : 
     149             :   // Transfer the temperature of the solid onto the flow channel
     150             :   {
     151         288 :     std::string class_name = "MeshAlignmentVariableTransferMaterial";
     152         288 :     InputParameters params = _factory.getValidParams(class_name);
     153         288 :     params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
     154         864 :     params.set<MaterialPropertyName>("property_name") = _T_wall_name + "_coupled";
     155         288 :     params.set<std::string>("paired_variable") = HeatConductionModel::TEMPERATURE;
     156         288 :     params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
     157         576 :     getTHMProblem().addMaterial(class_name, genName(name(), "T_wall_transfer_mat"), params);
     158         288 :   }
     159             : 
     160             :   // Transfer the temperature of the solid onto the flow channel as aux variable for visualization
     161             :   {
     162         288 :     std::string class_name = "VariableValueTransferAux";
     163         288 :     InputParameters params = _factory.getValidParams(class_name);
     164         576 :     params.set<AuxVariableName>("variable") = _T_wall_name;
     165         864 :     params.set<std::vector<BoundaryName>>("boundary") = {getChannelSideName()};
     166         576 :     params.set<BoundaryName>("paired_boundary") = getHSBoundaryName(this);
     167         288 :     params.set<std::vector<VariableName>>("paired_variable") =
     168         576 :         std::vector<VariableName>(1, HeatConductionModel::TEMPERATURE);
     169         576 :     getTHMProblem().addAuxKernel(class_name, genName(name(), "T_wall_transfer"), params);
     170         288 :   }
     171        1152 : }
     172             : 
     173             : const BoundaryName &
     174         288 : HeatTransferFromHeatStructure1Phase::getChannelSideName() const
     175             : {
     176             :   const FlowChannel1PhaseBase & flow_channel =
     177         288 :       getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
     178         288 :   return flow_channel.getNodesetName();
     179             : }

Generated by: LCOV version 1.14