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 3722 : HeatConductionModel::validParams() 22 : { 23 3722 : InputParameters params = MooseObject::validParams(); 24 3722 : params.addPrivateParam<THMProblem *>("_thm_problem"); 25 3722 : params.addPrivateParam<HeatStructureInterface *>("_hs"); 26 7444 : params.addRequiredParam<Real>("scaling_factor_temperature", 27 : "Scaling factor for solid temperature variable."); 28 3722 : params.registerBase("THM:heat_conduction_model"); 29 3722 : 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 1861 : HeatConductionModel::HeatConductionModel(const InputParameters & params) 42 : : MooseObject(params), 43 1861 : _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")), 44 1861 : _factory(_app.getFactory()), 45 1861 : _hs_interface(*params.getCheckedPointerParam<HeatStructureInterface *>("_hs")), 46 3722 : _geometrical_component( 47 1861 : dynamic_cast<GeometricalComponent &>(_hs_interface)), // TODO: do something safer 48 3722 : _comp_name(name()) 49 : { 50 1861 : } 51 : 52 : void 53 1709 : HeatConductionModel::addVariables() 54 : { 55 1709 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 56 1709 : const Real & scaling_factor = getParam<Real>("scaling_factor_temperature"); 57 : 58 1709 : _sim.addSimVariable(true, TEMPERATURE, _fe_type, subdomain_names, scaling_factor); 59 1709 : } 60 : 61 : void 62 1657 : HeatConductionModel::addInitialConditions() 63 : { 64 1657 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 65 4971 : _sim.addFunctionIC(TEMPERATURE, _hs_interface.getInitialT(), subdomain_names); 66 1657 : } 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 501 : HeatConductionModel::addHeatEquationXYZ() 88 : { 89 501 : const auto & blocks = _geometrical_component.getSubdomainNames(); 90 : 91 : // add transient term 92 501 : if (_geometrical_component.problemIsTransient()) 93 : { 94 501 : std::string class_name = "ADHeatConductionTimeDerivative"; 95 501 : InputParameters pars = _factory.getValidParams(class_name); 96 1002 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 97 1002 : pars.set<std::vector<SubdomainName>>("block") = blocks; 98 1002 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 99 1002 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 100 501 : pars.set<bool>("use_displaced_mesh") = false; 101 1002 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 102 501 : } 103 : // add diffusion term 104 : { 105 501 : std::string class_name = "ADHeatConduction"; 106 501 : InputParameters pars = _factory.getValidParams(class_name); 107 1002 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 108 1002 : pars.set<std::vector<SubdomainName>>("block") = blocks; 109 1002 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 110 501 : pars.set<bool>("use_displaced_mesh") = false; 111 1002 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 112 501 : } 113 501 : } 114 : 115 : void 116 1208 : HeatConductionModel::addHeatEquationRZ() 117 : { 118 : HeatStructureCylindricalBase & hs_cyl = 119 1208 : dynamic_cast<HeatStructureCylindricalBase &>(_geometrical_component); 120 : 121 1208 : const auto & blocks = hs_cyl.getSubdomainNames(); 122 1208 : const auto & position = hs_cyl.getPosition(); 123 1208 : const auto & direction = hs_cyl.getDirection(); 124 : 125 : // add transient term 126 1208 : if (_geometrical_component.problemIsTransient()) 127 : { 128 1189 : std::string class_name = "ADHeatConductionTimeDerivativeRZ"; 129 1189 : InputParameters pars = _factory.getValidParams(class_name); 130 2378 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 131 2378 : pars.set<std::vector<SubdomainName>>("block") = blocks; 132 2378 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 133 2378 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 134 1189 : pars.set<bool>("use_displaced_mesh") = false; 135 1189 : pars.set<Point>("axis_point") = position; 136 1189 : pars.set<RealVectorValue>("axis_dir") = direction; 137 2378 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 138 1189 : } 139 : // add diffusion term 140 : { 141 1208 : std::string class_name = "ADHeatConductionRZ"; 142 1208 : InputParameters pars = _factory.getValidParams(class_name); 143 2416 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 144 2416 : pars.set<std::vector<SubdomainName>>("block") = blocks; 145 2416 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 146 1208 : pars.set<bool>("use_displaced_mesh") = false; 147 1208 : pars.set<Point>("axis_point") = position; 148 1208 : pars.set<RealVectorValue>("axis_dir") = direction; 149 2416 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 150 1208 : } 151 1208 : }