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

Generated by: LCOV version 1.14