LCOV - code coverage report
Current view: top level - src/components - FlowChannel1PhaseBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 72 80 90.0 %
Date: 2026-05-29 20:41:18 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 "FlowChannel1PhaseBase.h"
      11             : #include "HeatTransfer1PhaseBase.h"
      12             : #include "SlopeReconstruction1DInterface.h"
      13             : #include "THMNames.h"
      14             : 
      15             : InputParameters
      16        4332 : FlowChannel1PhaseBase::validParams()
      17             : {
      18        4332 :   InputParameters params = FlowChannelBase::validParams();
      19             : 
      20        8664 :   params.addParam<FunctionName>("initial_p", "Initial pressure in the flow channel [Pa]");
      21        8664 :   params.addParam<FunctionName>("initial_vel", "Initial velocity in the flow channel [m/s]");
      22        8664 :   params.addParam<FunctionName>("initial_T", "Initial temperature in the flow channel [K]");
      23        8664 :   params.addParam<FunctionName>("D_h", "Hydraulic diameter [m]");
      24        8664 :   params.addParam<bool>("enable_heat_conduction", false, "Enable heat conduction?");
      25        8664 :   params.addParam<MooseEnum>(
      26             :       "rdg_slope_reconstruction",
      27       12996 :       SlopeReconstruction1DInterface<true>::getSlopeReconstructionMooseEnum("None"),
      28             :       "Slope reconstruction type for rDG spatial discretization");
      29             : 
      30        8664 :   params.addParam<Real>("p_ref", 101.325e3, "Reference pressure [Pa]");
      31        8664 :   params.addParam<Real>("T_ref", 273.15, "Reference temperature [K]");
      32        8664 :   params.addParam<Real>("vel_ref", 1.0, "Reference velocity [m/s]");
      33             : 
      34        8664 :   params.declareControllable("initial_p initial_T initial_vel");
      35        8664 :   params.addParamNamesToGroup("initial_p initial_T initial_vel", "Variable initialization");
      36        8664 :   params.addParamNamesToGroup("rdg_slope_reconstruction", "Numerical scheme");
      37             : 
      38        4332 :   return params;
      39           0 : }
      40             : 
      41        2165 : FlowChannel1PhaseBase::FlowChannel1PhaseBase(const InputParameters & params)
      42             :   : FlowChannelBase(params),
      43             : 
      44        4330 :     _numerical_flux_name(genName(name(), "numerical_flux")),
      45        6495 :     _rdg_slope_reconstruction(getParam<MooseEnum>("rdg_slope_reconstruction"))
      46             : {
      47        2165 : }
      48             : 
      49             : void
      50        2142 : FlowChannel1PhaseBase::init()
      51             : {
      52        2142 :   FlowChannelBase::init();
      53        2142 : }
      54             : 
      55             : std::shared_ptr<FlowModel>
      56        2142 : FlowChannel1PhaseBase::buildFlowModel()
      57             : {
      58        2142 :   const std::string class_name = flowModelClassName();
      59        2142 :   InputParameters pars = _factory.getValidParams(class_name);
      60        2142 :   pars.set<THMProblem *>("_thm_problem") = &getTHMProblem();
      61        2142 :   pars.set<FlowChannelBase *>("_flow_channel") = this;
      62        2142 :   pars.set<UserObjectName>("numerical_flux") = _numerical_flux_name;
      63        2142 :   pars.set<bool>("output_vector_velocity") = getTHMProblem().getVectorValuedVelocity();
      64        2142 :   pars.applyParameters(parameters());
      65        4284 :   return _factory.create<FlowModel>(class_name, name(), pars, 0);
      66        2142 : }
      67             : 
      68             : void
      69        2088 : FlowChannel1PhaseBase::check() const
      70             : {
      71        2088 :   FlowChannelBase::check();
      72             : 
      73        2088 :   checkFluidProperties();
      74             : 
      75             :   // only 1-phase flow compatible heat transfers are allowed
      76        2612 :   for (unsigned int i = 0; i < _heat_transfer_names.size(); i++)
      77             :   {
      78             :     if (!hasComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]))
      79           0 :       logError("Coupled heat source '",
      80             :                _heat_transfer_names[i],
      81             :                "' is not compatible with single phase flow channel. Use single phase heat transfer "
      82             :                "component instead.");
      83             :   }
      84             : 
      85             :   bool ics_set = true;
      86        8361 :   for (const auto & ic_param : ICParameters())
      87       14542 :     ics_set = ics_set && isParamValid(ic_param);
      88        2088 :   ics_set = ics_set || getTHMProblem().hasInitialConditionsFromFile();
      89             : 
      90          18 :   if (!ics_set && !_app.isRestarting())
      91             :   {
      92             :     // create a list of the missing IC parameters
      93           0 :     std::ostringstream oss;
      94           0 :     for (const auto & ic_param : ICParameters())
      95           0 :       if (!isParamValid(ic_param))
      96           0 :         oss << " " << ic_param;
      97             : 
      98           0 :     logError("The following initial condition parameters are missing:", oss.str());
      99           0 :   }
     100        2088 : }
     101             : 
     102             : void
     103        2046 : FlowChannel1PhaseBase::addMooseObjects()
     104             : {
     105        2046 :   FlowChannelBase::addMooseObjects();
     106             : 
     107        2046 :   if (!_pipe_pars_transferred)
     108        2046 :     addHydraulicDiameterMaterial();
     109        2046 : }
     110             : 
     111             : void
     112        2046 : FlowChannel1PhaseBase::addHydraulicDiameterMaterial()
     113             : {
     114        4092 :   const std::string mat_name = genName(name(), "D_h_material");
     115             : 
     116        4092 :   if (isParamValid("D_h"))
     117             :   {
     118         640 :     const FunctionName & D_h_fn_name = getParam<FunctionName>("D_h");
     119             : 
     120         640 :     const std::string class_name = "ADGenericFunctionMaterial";
     121         640 :     InputParameters params = _factory.getValidParams(class_name);
     122         640 :     params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
     123        1920 :     params.set<std::vector<std::string>>("prop_names") = {THM::HYDRAULIC_DIAMETER};
     124        1920 :     params.set<std::vector<FunctionName>>("prop_values") = {D_h_fn_name};
     125         640 :     getTHMProblem().addMaterial(class_name, mat_name, params);
     126         640 :   }
     127             :   else
     128             :   {
     129        1406 :     const std::string class_name = "ADHydraulicDiameterCircularMaterial";
     130        1406 :     InputParameters params = _factory.getValidParams(class_name);
     131        2812 :     params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
     132        2812 :     params.set<MaterialPropertyName>("D_h_name") = THM::HYDRAULIC_DIAMETER;
     133        4218 :     params.set<std::vector<VariableName>>("A") = {THM::AREA};
     134        1406 :     getTHMProblem().addMaterial(class_name, mat_name, params);
     135        1406 :   }
     136        2686 : }
     137             : 
     138             : void
     139        2046 : FlowChannel1PhaseBase::getHeatTransferVariableNames()
     140             : {
     141        2046 :   FlowChannelBase::getHeatTransferVariableNames();
     142             : 
     143        2547 :   for (unsigned int i = 0; i < _n_heat_transfer_connections; i++)
     144             :   {
     145             :     const HeatTransfer1PhaseBase & heat_transfer =
     146         501 :         getComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]);
     147             : 
     148         501 :     _Hw_1phase_names.push_back(heat_transfer.getWallHeatTransferCoefficient1PhaseName());
     149             :   }
     150        2046 : }

Generated by: LCOV version 1.14