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 8422 : FlowChannel1PhaseBase::validParams() 17 : { 18 8422 : InputParameters params = FlowChannelBase::validParams(); 19 : 20 16844 : params.addParam<FunctionName>("initial_p", "Initial pressure in the flow channel [Pa]"); 21 16844 : params.addParam<FunctionName>("initial_vel", "Initial velocity in the flow channel [m/s]"); 22 16844 : params.addParam<FunctionName>("initial_T", "Initial temperature in the flow channel [K]"); 23 16844 : params.addParam<FunctionName>("D_h", "Hydraulic diameter [m]"); 24 16844 : params.addParam<MooseEnum>( 25 : "rdg_slope_reconstruction", 26 25266 : SlopeReconstruction1DInterface<true>::getSlopeReconstructionMooseEnum("None"), 27 : "Slope reconstruction type for rDG spatial discretization"); 28 : 29 16844 : params.addParam<Real>("p_ref", 101.325e3, "Reference pressure [Pa]"); 30 16844 : params.addParam<Real>("T_ref", 273.15, "Reference temperature [K]"); 31 16844 : params.addParam<Real>("vel_ref", 1.0, "Reference velocity [m/s]"); 32 : 33 16844 : params.declareControllable("initial_p initial_T initial_vel D_h"); 34 16844 : params.addParamNamesToGroup("initial_p initial_T initial_vel", "Variable initialization"); 35 16844 : params.addParamNamesToGroup("rdg_slope_reconstruction", "Numerical scheme"); 36 : 37 8422 : return params; 38 0 : } 39 : 40 4210 : FlowChannel1PhaseBase::FlowChannel1PhaseBase(const InputParameters & params) 41 : : FlowChannelBase(params), 42 : 43 8420 : _numerical_flux_name(genName(name(), "numerical_flux")), 44 12630 : _rdg_slope_reconstruction(getParam<MooseEnum>("rdg_slope_reconstruction")) 45 : { 46 4210 : } 47 : 48 : void 49 4181 : FlowChannel1PhaseBase::init() 50 : { 51 4181 : FlowChannelBase::init(); 52 4181 : } 53 : 54 : std::shared_ptr<FlowModel> 55 4181 : FlowChannel1PhaseBase::buildFlowModel() 56 : { 57 4181 : const std::string class_name = flowModelClassName(); 58 4181 : InputParameters pars = _factory.getValidParams(class_name); 59 4181 : pars.set<THMProblem *>("_thm_problem") = &getTHMProblem(); 60 4181 : pars.set<FlowChannelBase *>("_flow_channel") = this; 61 4181 : pars.set<FunctionName>("A_function") = _area_function; 62 4181 : pars.set<UserObjectName>("numerical_flux") = _numerical_flux_name; 63 4181 : pars.set<bool>("output_vector_velocity") = getTHMProblem().getVectorValuedVelocity(); 64 4181 : pars.applyParameters(parameters()); 65 8362 : return _factory.create<FlowModel>(class_name, name(), pars, 0); 66 4181 : } 67 : 68 : void 69 4071 : FlowChannel1PhaseBase::check() const 70 : { 71 4071 : FlowChannelBase::check(); 72 : 73 4071 : checkFluidProperties(); 74 : 75 : // only 1-phase flow compatible heat transfers are allowed 76 5095 : 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 16303 : for (const auto & ic_param : ICParameters()) 87 28411 : ics_set = ics_set && isParamValid(ic_param); 88 4071 : ics_set = ics_set || getTHMProblem().hasInitialConditionsFromFile(); 89 : 90 24 : 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 4071 : } 101 : 102 : void 103 4067 : FlowChannel1PhaseBase::addMooseObjects() 104 : { 105 4067 : FlowChannelBase::addMooseObjects(); 106 : 107 4067 : if (!_pipe_pars_transferred) 108 4067 : addHydraulicDiameterMaterial(); 109 4067 : } 110 : 111 : void 112 4067 : FlowChannel1PhaseBase::addHydraulicDiameterMaterial() 113 : { 114 8134 : const std::string mat_name = genName(name(), "D_h_material"); 115 : 116 8134 : if (isParamValid("D_h")) 117 : { 118 1491 : const FunctionName & D_h_fn_name = getParam<FunctionName>("D_h"); 119 : 120 1491 : const std::string class_name = "ADGenericFunctionMaterial"; 121 1491 : InputParameters params = _factory.getValidParams(class_name); 122 1491 : params.set<std::vector<SubdomainName>>("block") = getSubdomainNames(); 123 4473 : params.set<std::vector<std::string>>("prop_names") = {THM::HYDRAULIC_DIAMETER}; 124 4473 : params.set<std::vector<FunctionName>>("prop_values") = {D_h_fn_name}; 125 1491 : getTHMProblem().addMaterial(class_name, mat_name, params); 126 : 127 2982 : makeFunctionControllableIfConstant(D_h_fn_name, "D_h"); 128 1491 : } 129 : else 130 : { 131 2576 : const std::string class_name = "ADHydraulicDiameterCircularMaterial"; 132 2576 : InputParameters params = _factory.getValidParams(class_name); 133 5152 : params.set<std::vector<SubdomainName>>("block") = getSubdomainNames(); 134 5152 : params.set<MaterialPropertyName>("D_h_name") = THM::HYDRAULIC_DIAMETER; 135 7728 : params.set<std::vector<VariableName>>("A") = {THM::AREA}; 136 2576 : getTHMProblem().addMaterial(class_name, mat_name, params); 137 2576 : } 138 5558 : } 139 : 140 : void 141 4067 : FlowChannel1PhaseBase::getHeatTransferVariableNames() 142 : { 143 4067 : FlowChannelBase::getHeatTransferVariableNames(); 144 : 145 5078 : for (unsigned int i = 0; i < _n_heat_transfer_connections; i++) 146 : { 147 : const HeatTransfer1PhaseBase & heat_transfer = 148 1011 : getComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]); 149 : 150 1011 : _Hw_1phase_names.push_back(heat_transfer.getWallHeatTransferCoefficient1PhaseName()); 151 : } 152 4067 : }