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 "HeatConductionModel.h" 11 : #include "THMProblem.h" 12 : #include "Factory.h" 13 : #include "Component.h" 14 : #include "ThermalHydraulicsApp.h" 15 : #include "HeatStructureInterface.h" 16 : #include "HeatStructureCylindricalBase.h" 17 : 18 : using namespace libMesh; 19 : 20 : InputParameters 21 3726 : HeatConductionModel::validParams() 22 : { 23 3726 : InputParameters params = MooseObject::validParams(); 24 3726 : params.addPrivateParam<THMProblem *>("_thm_problem"); 25 3726 : params.addPrivateParam<HeatStructureInterface *>("_hs"); 26 7452 : params.addRequiredParam<Real>("scaling_factor_temperature", 27 : "Scaling factor for solid temperature variable."); 28 3726 : params.registerBase("THM:heat_conduction_model"); 29 3726 : return params; 30 0 : } 31 : 32 : registerMooseObject("ThermalHydraulicsApp", HeatConductionModel); 33 : 34 : const std::string HeatConductionModel::DENSITY = "density"; 35 : const std::string HeatConductionModel::TEMPERATURE = "T_solid"; 36 : const std::string HeatConductionModel::THERMAL_CONDUCTIVITY = "thermal_conductivity"; 37 : const std::string HeatConductionModel::SPECIFIC_HEAT_CONSTANT_PRESSURE = "specific_heat"; 38 : 39 : FEType HeatConductionModel::_fe_type(FIRST, LAGRANGE); 40 : 41 1863 : HeatConductionModel::HeatConductionModel(const InputParameters & params) 42 : : MooseObject(params), 43 1863 : _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")), 44 1863 : _factory(_app.getFactory()), 45 1863 : _hs_interface(*params.getCheckedPointerParam<HeatStructureInterface *>("_hs")), 46 3726 : _geometrical_component( 47 1863 : dynamic_cast<GeometricalComponent &>(_hs_interface)), // TODO: do something safer 48 3726 : _comp_name(name()) 49 : { 50 1863 : } 51 : 52 : void 53 1711 : HeatConductionModel::addVariables() 54 : { 55 1711 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 56 1711 : const Real & scaling_factor = getParam<Real>("scaling_factor_temperature"); 57 : 58 1711 : _sim.addSimVariable(true, TEMPERATURE, _fe_type, subdomain_names, scaling_factor); 59 1711 : } 60 : 61 : void 62 1659 : HeatConductionModel::addInitialConditions() 63 : { 64 1659 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 65 4977 : _sim.addFunctionIC(TEMPERATURE, _hs_interface.getInitialT(), subdomain_names); 66 1659 : } 67 : 68 : void 69 36 : HeatConductionModel::addMaterials() 70 : { 71 36 : const auto & blocks = _geometrical_component.getSubdomainNames(); 72 : const auto & material_names = 73 36 : _geometrical_component.getParam<std::vector<std::string>>("materials"); 74 : 75 108 : for (std::size_t i = 0; i < blocks.size(); i++) 76 : { 77 72 : std::string class_name = "ADSolidMaterial"; 78 72 : InputParameters params = _factory.getValidParams(class_name); 79 216 : params.set<std::vector<SubdomainName>>("block") = {blocks[i]}; 80 216 : params.set<std::vector<VariableName>>("T") = {TEMPERATURE}; 81 144 : params.set<UserObjectName>("properties") = material_names[i]; 82 144 : _sim.addMaterial(class_name, genName(blocks[i], "mat"), params); 83 72 : } 84 36 : } 85 : 86 : void 87 502 : HeatConductionModel::addHeatEquationXYZ() 88 : { 89 502 : const auto & blocks = _geometrical_component.getSubdomainNames(); 90 : 91 : // add transient term 92 502 : if (_geometrical_component.problemIsTransient()) 93 : { 94 502 : std::string class_name = "ADHeatConductionTimeDerivative"; 95 502 : InputParameters pars = _factory.getValidParams(class_name); 96 1004 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 97 1004 : pars.set<std::vector<SubdomainName>>("block") = blocks; 98 1004 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 99 1004 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 100 502 : pars.set<bool>("use_displaced_mesh") = false; 101 1004 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 102 502 : } 103 : // add diffusion term 104 : { 105 502 : std::string class_name = "ADHeatConduction"; 106 502 : InputParameters pars = _factory.getValidParams(class_name); 107 1004 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 108 1004 : pars.set<std::vector<SubdomainName>>("block") = blocks; 109 1004 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 110 502 : pars.set<bool>("use_displaced_mesh") = false; 111 1004 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 112 502 : } 113 502 : } 114 : 115 : void 116 1209 : HeatConductionModel::addHeatEquationRZ() 117 : { 118 : HeatStructureCylindricalBase & hs_cyl = 119 1209 : dynamic_cast<HeatStructureCylindricalBase &>(_geometrical_component); 120 : 121 1209 : const auto & blocks = hs_cyl.getSubdomainNames(); 122 1209 : const auto & position = hs_cyl.getPosition(); 123 1209 : const auto & direction = hs_cyl.getDirection(); 124 : 125 : // add transient term 126 1209 : if (_geometrical_component.problemIsTransient()) 127 : { 128 1190 : std::string class_name = "ADHeatConductionTimeDerivativeRZ"; 129 1190 : InputParameters pars = _factory.getValidParams(class_name); 130 2380 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 131 2380 : pars.set<std::vector<SubdomainName>>("block") = blocks; 132 2380 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 133 2380 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 134 1190 : pars.set<bool>("use_displaced_mesh") = false; 135 1190 : pars.set<Point>("axis_point") = position; 136 1190 : pars.set<RealVectorValue>("axis_dir") = direction; 137 2380 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 138 1190 : } 139 : // add diffusion term 140 : { 141 1209 : std::string class_name = "ADHeatConductionRZ"; 142 1209 : InputParameters pars = _factory.getValidParams(class_name); 143 2418 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 144 2418 : pars.set<std::vector<SubdomainName>>("block") = blocks; 145 2418 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 146 1209 : pars.set<bool>("use_displaced_mesh") = false; 147 1209 : pars.set<Point>("axis_point") = position; 148 1209 : pars.set<RealVectorValue>("axis_dir") = direction; 149 2418 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 150 1209 : } 151 1209 : }