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 "HeatTransferBase.h" 11 : #include "FlowModelSinglePhase.h" 12 : #include "FlowChannelBase.h" 13 : #include "ClosuresBase.h" 14 : #include "MooseUtils.h" 15 : 16 : InputParameters 17 2042 : HeatTransferBase::validParams() 18 : { 19 2042 : InputParameters params = ConnectorBase::validParams(); 20 4084 : params.addDeprecatedParam<std::string>( 21 : "pipe", "Name of pipe component to connect", "Use 'flow_channel' parameter instead."); 22 4084 : params.addRequiredParam<std::string>("flow_channel", 23 : "Name of flow channel component to connect to"); 24 4084 : params.addParam<bool>( 25 4084 : "P_hf_transferred", false, "Is heat flux perimeter transferred from an external source?"); 26 4084 : params.addParam<FunctionName>("P_hf", "Heat flux perimeter [m]"); 27 4084 : params.declareControllable("P_hf"); 28 2042 : return params; 29 0 : } 30 : 31 1021 : HeatTransferBase::HeatTransferBase(const InputParameters & parameters) 32 : : ConnectorBase(parameters), 33 1021 : _flow_channel_name(getParam<std::string>("flow_channel")), 34 2042 : _P_hf_transferred(getParam<bool>("P_hf_transferred")), 35 3063 : _P_hf_provided(isParamValid("P_hf")) 36 : { 37 1021 : addDependency(_flow_channel_name); 38 1021 : } 39 : 40 : void 41 970 : HeatTransferBase::init() 42 : { 43 970 : ConnectorBase::init(); 44 : 45 970 : checkComponentOfTypeExistsByName<FlowChannelBase>(_flow_channel_name); 46 : 47 : if (hasComponentByName<FlowChannelBase>(_flow_channel_name)) 48 : { 49 : const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name); 50 : 51 : // add the name of this heat transfer component to list for flow channel 52 966 : flow_channel.addHeatTransferName(name()); 53 : 54 : // get various data from flow channel 55 966 : _flow_channel_subdomains = flow_channel.getSubdomainNames(); 56 966 : _model_type = flow_channel.getFlowModelID(); 57 : _fp_name = flow_channel.getFluidPropertiesName(); 58 966 : _A_fn_name = flow_channel.getAreaFunctionName(); 59 966 : _closures_objects = flow_channel.getClosuresObjects(); 60 : } 61 970 : } 62 : 63 : void 64 970 : HeatTransferBase::initSecondary() 65 : { 66 : ConnectorBase::initSecondary(); 67 : 68 : // determine names of heat transfer variables 69 970 : if (hasComponentByName<FlowChannelBase>(_flow_channel_name)) 70 : { 71 : const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name); 72 : 73 966 : const std::string suffix = flow_channel.getHeatTransferNamesSuffix(name()); 74 : 75 966 : _P_hf_name = FlowModel::HEAT_FLUX_PERIMETER + suffix; 76 966 : _T_wall_name = FlowModel::TEMPERATURE_WALL + suffix; 77 966 : _T_wall_mat_name = FlowModel::TEMPERATURE_WALL + suffix; 78 1932 : _q_wall_name = FlowModel::HEAT_FLUX_WALL + suffix; 79 : } 80 970 : } 81 : 82 : void 83 950 : HeatTransferBase::check() const 84 : { 85 : ConnectorBase::check(); 86 950 : } 87 : 88 : void 89 950 : HeatTransferBase::addVariables() 90 : { 91 : // heat flux perimeter variable 92 950 : if (!_P_hf_transferred) 93 950 : addHeatedPerimeter(); 94 950 : } 95 : 96 : void 97 987 : HeatTransferBase::addMooseObjects() 98 : { 99 : // create heat flux perimeter aux if not transferred from external app 100 987 : if (!_P_hf_transferred) 101 : { 102 987 : const std::string class_name = "FunctionAux"; 103 987 : InputParameters params = _factory.getValidParams(class_name); 104 1974 : params.set<AuxVariableName>("variable") = {_P_hf_name}; 105 987 : params.set<std::vector<SubdomainName>>("block") = _flow_channel_subdomains; 106 987 : params.set<FunctionName>("function") = _P_hf_fn_name; 107 : 108 987 : ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum()); 109 3948 : execute_on = {EXEC_TIMESTEP_BEGIN, EXEC_INITIAL}; 110 987 : params.set<ExecFlagEnum>("execute_on") = execute_on; 111 : 112 1974 : getTHMProblem().addAuxKernel(class_name, genName(name(), "P_hf_auxkernel"), params); 113 987 : } 114 1974 : } 115 : 116 : void 117 950 : HeatTransferBase::addHeatedPerimeter() 118 : { 119 950 : getTHMProblem().addSimVariable( 120 950 : false, _P_hf_name, getTHMProblem().getFlowFEType(), _flow_channel_subdomains); 121 : 122 : // create heat flux perimeter variable if not transferred from external app 123 950 : if (!_P_hf_transferred) 124 : { 125 950 : if (_P_hf_provided) 126 : { 127 1260 : _P_hf_fn_name = getParam<FunctionName>("P_hf"); 128 : } 129 : // create heat flux perimeter function if not provided; assume circular flow channel 130 : else 131 : { 132 640 : _P_hf_fn_name = genName(name(), "P_hf_fn"); 133 : 134 320 : const std::string class_name = "GeneralizedCircumference"; 135 320 : InputParameters params = _factory.getValidParams(class_name); 136 320 : params.set<FunctionName>("area_function") = _A_fn_name; 137 320 : getTHMProblem().addFunction(class_name, _P_hf_fn_name, params); 138 : 139 640 : makeFunctionControllableIfConstant(_P_hf_fn_name, "P_hf"); 140 320 : } 141 : 142 950 : if (!_app.isRestarting()) 143 934 : getTHMProblem().addFunctionIC(_P_hf_name, _P_hf_fn_name, _flow_channel_subdomains); 144 : } 145 950 : } 146 : 147 : const VariableName & 148 1011 : HeatTransferBase::getHeatedPerimeterName() const 149 : { 150 1011 : checkSetupStatus(INITIALIZED_SECONDARY); 151 : 152 1011 : return _P_hf_name; 153 : } 154 : 155 : const VariableName & 156 1011 : HeatTransferBase::getWallTemperatureName() const 157 : { 158 1011 : checkSetupStatus(INITIALIZED_SECONDARY); 159 : 160 1011 : return _T_wall_name; 161 : } 162 : 163 : const MaterialPropertyName & 164 1011 : HeatTransferBase::getWallTemperatureMatName() const 165 : { 166 1011 : checkSetupStatus(INITIALIZED_SECONDARY); 167 : 168 1011 : return _T_wall_mat_name; 169 : } 170 : 171 : const MaterialPropertyName & 172 1011 : HeatTransferBase::getWallHeatFluxName() const 173 : { 174 1011 : return _q_wall_name; 175 : } 176 : 177 : const UserObjectName & 178 0 : HeatTransferBase::getFluidPropertiesName() const 179 : { 180 0 : checkSetupStatus(INITIALIZED_PRIMARY); 181 : 182 0 : return _fp_name; 183 : }