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 2116 : HeatConductionModel::validParams() 22 : { 23 2116 : InputParameters params = MooseObject::validParams(); 24 2116 : params.addPrivateParam<THMProblem *>("_thm_problem"); 25 2116 : params.addPrivateParam<HeatStructureInterface *>("_hs"); 26 4232 : params.addRequiredParam<Real>("scaling_factor_temperature", 27 : "Scaling factor for solid temperature variable."); 28 2116 : params.registerBase("THM:heat_conduction_model"); 29 2116 : 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 1058 : HeatConductionModel::HeatConductionModel(const InputParameters & params) 42 : : MooseObject(params), 43 1058 : _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")), 44 1058 : _factory(_app.getFactory()), 45 1058 : _hs_interface(*params.getCheckedPointerParam<HeatStructureInterface *>("_hs")), 46 2116 : _geometrical_component( 47 1058 : dynamic_cast<GeometricalComponent &>(_hs_interface)), // TODO: do something safer 48 2116 : _comp_name(name()) 49 : { 50 1058 : } 51 : 52 : void 53 908 : HeatConductionModel::addVariables() 54 : { 55 908 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 56 908 : const Real & scaling_factor = getParam<Real>("scaling_factor_temperature"); 57 : 58 908 : _sim.addSimVariable(true, TEMPERATURE, _fe_type, subdomain_names, scaling_factor); 59 908 : } 60 : 61 : void 62 868 : HeatConductionModel::addInitialConditions() 63 : { 64 868 : const auto & subdomain_names = _geometrical_component.getSubdomainNames(); 65 2604 : _sim.addFunctionIC(TEMPERATURE, _hs_interface.getInitialT(), subdomain_names); 66 868 : } 67 : 68 : void 69 292 : HeatConductionModel::addHeatEquationXYZ() 70 : { 71 292 : const auto & blocks = _geometrical_component.getSubdomainNames(); 72 : 73 : // add transient term 74 292 : if (_geometrical_component.problemIsTransient()) 75 : { 76 292 : std::string class_name = "ADHeatConductionTimeDerivative"; 77 292 : InputParameters pars = _factory.getValidParams(class_name); 78 584 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 79 584 : pars.set<std::vector<SubdomainName>>("block") = blocks; 80 584 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 81 584 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 82 292 : pars.set<bool>("use_displaced_mesh") = false; 83 584 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 84 292 : } 85 : // add diffusion term 86 : { 87 292 : std::string class_name = "ADHeatConduction"; 88 292 : InputParameters pars = _factory.getValidParams(class_name); 89 584 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 90 584 : pars.set<std::vector<SubdomainName>>("block") = blocks; 91 584 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 92 292 : pars.set<bool>("use_displaced_mesh") = false; 93 584 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 94 292 : } 95 292 : } 96 : 97 : void 98 616 : HeatConductionModel::addHeatEquationRZ() 99 : { 100 : HeatStructureCylindricalBase & hs_cyl = 101 616 : dynamic_cast<HeatStructureCylindricalBase &>(_geometrical_component); 102 : 103 616 : const auto & blocks = hs_cyl.getSubdomainNames(); 104 616 : const auto & position = hs_cyl.getPosition(); 105 616 : const auto & direction = hs_cyl.getDirection(); 106 : 107 : // add transient term 108 616 : if (_geometrical_component.problemIsTransient()) 109 : { 110 607 : std::string class_name = "ADHeatConductionTimeDerivativeRZ"; 111 607 : InputParameters pars = _factory.getValidParams(class_name); 112 1214 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 113 1214 : pars.set<std::vector<SubdomainName>>("block") = blocks; 114 1214 : pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE; 115 1214 : pars.set<MaterialPropertyName>("density_name") = DENSITY; 116 607 : pars.set<bool>("use_displaced_mesh") = false; 117 607 : pars.set<Point>("axis_point") = position; 118 607 : pars.set<RealVectorValue>("axis_dir") = direction; 119 1214 : _sim.addKernel(class_name, genName(_comp_name, "td"), pars); 120 607 : } 121 : // add diffusion term 122 : { 123 616 : std::string class_name = "ADHeatConductionRZ"; 124 616 : InputParameters pars = _factory.getValidParams(class_name); 125 1232 : pars.set<NonlinearVariableName>("variable") = TEMPERATURE; 126 1232 : pars.set<std::vector<SubdomainName>>("block") = blocks; 127 1232 : pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY; 128 616 : pars.set<bool>("use_displaced_mesh") = false; 129 616 : pars.set<Point>("axis_point") = position; 130 616 : pars.set<RealVectorValue>("axis_dir") = direction; 131 1232 : _sim.addKernel(class_name, genName(_comp_name, "hc"), pars); 132 616 : } 133 616 : }