LCOV - code coverage report
Current view: top level - src/closures - Closures1PhaseSimple.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 53 54 98.1 %
Date: 2025-07-30 13:02:48 Functions: 7 7 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 "Closures1PhaseSimple.h"
      11             : #include "FlowModelSinglePhase.h"
      12             : #include "FlowChannel1Phase.h"
      13             : #include "HeatTransfer1PhaseBase.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", Closures1PhaseSimple);
      16             : 
      17             : InputParameters
      18        4557 : Closures1PhaseSimple::validParams()
      19             : {
      20        4557 :   InputParameters params = Closures1PhaseBase::validParams();
      21             : 
      22        4557 :   params.addClassDescription("Simple 1-phase closures");
      23             : 
      24        4557 :   return params;
      25           0 : }
      26             : 
      27        2274 : Closures1PhaseSimple::Closures1PhaseSimple(const InputParameters & params)
      28        2274 :   : Closures1PhaseBase(params)
      29             : {
      30        2274 : }
      31             : 
      32             : void
      33        3445 : Closures1PhaseSimple::checkFlowChannel(const FlowChannelBase & flow_channel) const
      34             : {
      35        6890 :   if (!flow_channel.isParamValid("f"))
      36           2 :     logComponentError(flow_channel.cname(),
      37             :                       "When using simple closures, the parameter 'f' must be provided.");
      38        3445 : }
      39             : 
      40             : void
      41         650 : Closures1PhaseSimple::checkHeatTransfer(const HeatTransferBase & heat_transfer,
      42             :                                         const FlowChannelBase & /*flow_channel*/) const
      43             : {
      44        1300 :   if (!heat_transfer.isParamValid("Hw"))
      45           4 :     logComponentError(heat_transfer.cname(),
      46             :                       "The parameter 'Hw' must be provided when using simple closures.");
      47         650 : }
      48             : 
      49             : void
      50        3443 : Closures1PhaseSimple::addMooseObjectsFlowChannel(const FlowChannelBase & flow_channel)
      51             : {
      52             :   const FlowChannel1Phase & flow_channel_1phase =
      53        3443 :       dynamic_cast<const FlowChannel1Phase &>(flow_channel);
      54             : 
      55             :   // wall friction material
      56        3443 :   addWallFrictionFunctionMaterial(flow_channel_1phase);
      57             : 
      58             :   const unsigned int n_ht_connections = flow_channel_1phase.getNumberOfHeatTransferConnections();
      59        3443 :   if (n_ht_connections > 0)
      60             :   {
      61             :     // wall heat transfer coefficient material
      62         593 :     if (n_ht_connections > 1)
      63         132 :       addWeightedAverageMaterial(flow_channel_1phase,
      64          44 :                                  flow_channel_1phase.getWallHTCNames1Phase(),
      65          44 :                                  flow_channel_1phase.getHeatedPerimeterNames(),
      66             :                                  FlowModelSinglePhase::HEAT_TRANSFER_COEFFICIENT_WALL);
      67             : 
      68             :     // wall temperature material
      69         593 :     if (flow_channel_1phase.getTemperatureMode())
      70             :     {
      71         521 :       if (n_ht_connections > 1)
      72           8 :         addAverageWallTemperatureMaterial(flow_channel_1phase);
      73             :       else
      74         513 :         addWallTemperatureFromAuxMaterial(flow_channel_1phase);
      75             :     }
      76             :     else
      77             :     {
      78          72 :       if (n_ht_connections > 1)
      79          36 :         addWallTemperatureFromHeatFluxMaterial(flow_channel_1phase);
      80             :     }
      81             :   }
      82        3443 : }
      83             : 
      84             : void
      85         637 : Closures1PhaseSimple::addMooseObjectsHeatTransfer(const HeatTransferBase & heat_transfer,
      86             :                                                   const FlowChannelBase & flow_channel)
      87             : {
      88             :   const HeatTransfer1PhaseBase & heat_transfer_1phase =
      89         637 :       dynamic_cast<const HeatTransfer1PhaseBase &>(heat_transfer);
      90         637 :   const FunctionName & Hw_fn_name = heat_transfer.getParam<FunctionName>("Hw");
      91             : 
      92             :   {
      93         637 :     const std::string class_name = "ADGenericFunctionMaterial";
      94         637 :     InputParameters params = _factory.getValidParams(class_name);
      95         637 :     params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
      96        1274 :     params.set<std::vector<std::string>>("prop_names") = {
      97        3185 :         heat_transfer_1phase.getWallHeatTransferCoefficient1PhaseName()};
      98        1911 :     params.set<std::vector<FunctionName>>("prop_values") = {Hw_fn_name};
      99         637 :     _sim.addMaterial(
     100         637 :         class_name, genName(heat_transfer.name(), "Hw_material", flow_channel.name()), params);
     101         637 :   }
     102             : 
     103        1274 :   heat_transfer.makeFunctionControllableIfConstant(Hw_fn_name, "Hw");
     104        1274 : }
     105             : 
     106             : void
     107          36 : Closures1PhaseSimple::addWallTemperatureFromHeatFluxMaterial(
     108             :     const FlowChannel1Phase & flow_channel) const
     109             : {
     110          36 :   const std::string class_name = "ADTemperatureWall3EqnMaterial";
     111          36 :   InputParameters params = _factory.getValidParams(class_name);
     112          72 :   params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
     113          72 :   params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE;
     114          72 :   params.set<MaterialPropertyName>("q_wall") = FlowModel::HEAT_FLUX_WALL;
     115          72 :   params.set<MaterialPropertyName>("Hw") = FlowModelSinglePhase::HEAT_TRANSFER_COEFFICIENT_WALL;
     116          72 :   _sim.addMaterial(class_name, genName(flow_channel.name(), "T_wall_mat"), params);
     117          72 : }

Generated by: LCOV version 1.14