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 "HeatTransferFromHeatStructure1Phase.h" 11 : #include "FlowChannel1PhaseBase.h" 12 : #include "HeatStructureBase.h" 13 : #include "HeatStructureCylindricalBase.h" 14 : #include "FlowModelSinglePhase.h" 15 : #include "THMMesh.h" 16 : #include "MooseUtils.h" 17 : 18 : registerMooseObject("ThermalHydraulicsApp", HeatTransferFromHeatStructure1Phase); 19 : 20 : InputParameters 21 322 : HeatTransferFromHeatStructure1Phase::validParams() 22 : { 23 322 : InputParameters params = HeatTransferFromTemperature1Phase::validParams(); 24 322 : params += HSBoundaryInterface::validParams(); 25 : 26 644 : params.addParam<MooseFunctorName>("scale", 1.0, "Functor by which to scale the heat flux"); 27 : 28 322 : params.addClassDescription("Connects a 1-phase flow channel and a heat structure"); 29 : 30 322 : return params; 31 0 : } 32 : 33 161 : HeatTransferFromHeatStructure1Phase::HeatTransferFromHeatStructure1Phase( 34 161 : const InputParameters & parameters) 35 : : HeatTransferFromTemperature1Phase(parameters), 36 : HSBoundaryInterface(this), 37 161 : _mesh_alignment(constMesh(), true) 38 : { 39 161 : } 40 : 41 : const libMesh::FEType & 42 147 : HeatTransferFromHeatStructure1Phase::getFEType() 43 : { 44 147 : return HeatConductionModel::feType(); 45 : } 46 : 47 : void 48 161 : HeatTransferFromHeatStructure1Phase::setupMesh() 49 : { 50 161 : if (hasComponentByName<HeatStructureBase>(_hs_name) && 51 159 : hasComponentByName<FlowChannel1PhaseBase>(_flow_channel_name)) 52 : { 53 : const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name); 54 : const FlowChannel1PhaseBase & flow_channel = 55 : getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name); 56 : 57 157 : if (!HSBoundaryIsValid(this)) 58 6 : return; 59 : 60 155 : const auto hs_boundary = getHSBoundaryName(this); 61 : 62 155 : _mesh_alignment.initialize(flow_channel.getElementIDs(), hs.getBoundaryInfo(hs_boundary)); 63 : 64 155 : if (!_mesh_alignment.meshesAreAligned()) 65 : { 66 4 : logError("The centers of the elements of flow channel '", 67 : _flow_channel_name, 68 : "' do not align with the centers of the specified heat structure side."); 69 : return; 70 : } 71 : 72 2168 : for (const auto & elem_id : _mesh_alignment.getPrimaryElemIDs()) 73 : { 74 2017 : if (_mesh_alignment.hasCoupledElemID(elem_id)) 75 2017 : getTHMProblem().augmentSparsity(elem_id, _mesh_alignment.getCoupledElemID(elem_id)); 76 : } 77 : } 78 : } 79 : 80 : void 81 149 : HeatTransferFromHeatStructure1Phase::check() const 82 : { 83 149 : HeatTransferFromTemperature1Phase::check(); 84 149 : HSBoundaryInterface::check(this); 85 149 : } 86 : 87 : void 88 147 : HeatTransferFromHeatStructure1Phase::addVariables() 89 : { 90 147 : HeatTransferFromTemperature1Phase::addVariables(); 91 : 92 : // wall temperature initial condition 93 147 : if (!getTHMProblem().hasInitialConditionsFromFile() && !_app.isRestarting()) 94 : { 95 141 : const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name); 96 282 : getTHMProblem().addFunctionIC(_T_wall_name, hs.getInitialT(), _flow_channel_subdomains); 97 : } 98 147 : } 99 : 100 : void 101 147 : HeatTransferFromHeatStructure1Phase::addMooseObjects() 102 : { 103 147 : HeatTransferFromTemperature1Phase::addMooseObjects(); 104 : 105 147 : ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum()); 106 588 : execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR}; 107 : 108 147 : const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name); 109 147 : const bool is_cylindrical = dynamic_cast<const HeatStructureCylindricalBase *>(&hs) != nullptr; 110 : const FlowChannel1PhaseBase & flow_channel = 111 147 : getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name); 112 : 113 294 : const UserObjectName heat_flux_uo_name = genName(name(), "heat_flux_uo"); 114 : { 115 147 : const std::string class_name = "ADHeatFluxFromHeatStructure3EqnUserObject"; 116 147 : InputParameters params = _factory.getValidParams(class_name); 117 147 : params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames(); 118 147 : params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment; 119 588 : params.set<MaterialPropertyName>("T_wall") = _T_wall_name + "_coupled"; 120 441 : params.set<std::vector<VariableName>>("P_hf") = {_P_hf_name}; 121 294 : params.set<MaterialPropertyName>("Hw") = _Hw_1phase_name; 122 294 : params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE; 123 441 : params.set<MooseFunctorName>("scale") = getParam<MooseFunctorName>("scale"); 124 147 : params.set<ExecFlagEnum>("execute_on") = execute_on; 125 147 : getTHMProblem().addUserObject(class_name, heat_flux_uo_name, params); 126 147 : } 127 : 128 : { 129 147 : const std::string class_name = "ADOneD3EqnEnergyHeatFlux"; 130 147 : InputParameters params = _factory.getValidParams(class_name); 131 294 : params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames(); 132 294 : params.set<NonlinearVariableName>("variable") = FlowModelSinglePhase::RHOEA; 133 147 : params.set<UserObjectName>("q_uo") = heat_flux_uo_name; 134 294 : getTHMProblem().addKernel(class_name, genName(name(), "heat_flux_kernel"), params); 135 147 : } 136 : 137 : { 138 147 : const std::string class_name = "ADHeatFlux3EqnBC"; 139 147 : InputParameters params = _factory.getValidParams(class_name); 140 441 : params.set<std::vector<BoundaryName>>("boundary") = {getHSBoundaryName(this)}; 141 294 : params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE; 142 147 : params.set<UserObjectName>("q_uo") = heat_flux_uo_name; 143 147 : params.set<Real>("P_hs_unit") = hs.getUnitPerimeter(getHSExternalBoundaryType(this)); 144 147 : params.set<unsigned int>("n_unit") = hs.getNumberOfUnits(); 145 147 : params.set<bool>("hs_coord_system_is_cylindrical") = is_cylindrical; 146 294 : getTHMProblem().addBoundaryCondition(class_name, genName(name(), "heat_flux_bc"), params); 147 147 : } 148 : 149 : // Transfer the temperature of the solid onto the flow channel 150 : { 151 147 : std::string class_name = "MeshAlignmentVariableTransferMaterial"; 152 147 : InputParameters params = _factory.getValidParams(class_name); 153 147 : params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames(); 154 441 : params.set<MaterialPropertyName>("property_name") = _T_wall_name + "_coupled"; 155 147 : params.set<std::string>("paired_variable") = HeatConductionModel::TEMPERATURE; 156 147 : params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment; 157 294 : getTHMProblem().addMaterial(class_name, genName(name(), "T_wall_transfer_mat"), params); 158 147 : } 159 : 160 : // Transfer the temperature of the solid onto the flow channel as aux variable for visualization 161 : { 162 147 : std::string class_name = "VariableValueTransferAux"; 163 147 : InputParameters params = _factory.getValidParams(class_name); 164 294 : params.set<AuxVariableName>("variable") = _T_wall_name; 165 441 : params.set<std::vector<BoundaryName>>("boundary") = {getChannelSideName()}; 166 294 : params.set<BoundaryName>("paired_boundary") = getHSBoundaryName(this); 167 147 : params.set<std::vector<VariableName>>("paired_variable") = 168 294 : std::vector<VariableName>(1, HeatConductionModel::TEMPERATURE); 169 294 : getTHMProblem().addAuxKernel(class_name, genName(name(), "T_wall_transfer"), params); 170 147 : } 171 588 : } 172 : 173 : const BoundaryName & 174 147 : HeatTransferFromHeatStructure1Phase::getChannelSideName() const 175 : { 176 : const FlowChannel1PhaseBase & flow_channel = 177 147 : getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name); 178 147 : return flow_channel.getNodesetName(); 179 : }