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 "HeatStructureBase.h" 11 : #include "SolidMaterialProperties.h" 12 : #include "ConstantFunction.h" 13 : 14 : InputParameters 15 3386 : HeatStructureBase::validParams() 16 : { 17 3386 : InputParameters params = Component2D::validParams(); 18 3386 : params += HeatStructureInterface::validParams(); 19 3386 : return params; 20 0 : } 21 : 22 1692 : HeatStructureBase::HeatStructureBase(const InputParameters & params) 23 : : Component2D(params), 24 : HeatStructureInterface(this), 25 1692 : _number_of_hs(_n_regions) 26 : { 27 1692 : } 28 : 29 : void 30 1665 : HeatStructureBase::init() 31 : { 32 : Component2D::init(); 33 1665 : HeatStructureInterface::init(); 34 1665 : } 35 : 36 : void 37 1645 : HeatStructureBase::check() const 38 : { 39 1645 : Component2D::check(); 40 1645 : HeatStructureInterface::check(); 41 1645 : } 42 : 43 : const unsigned int & 44 0 : HeatStructureBase::getIndexFromName(const std::string & name) const 45 : { 46 0 : return _name_index.at(name); 47 : } 48 : 49 : bool 50 7105 : HeatStructureBase::usingSecondOrderMesh() const 51 : { 52 7105 : return HeatConductionModel::feType().order == SECOND; 53 : } 54 : 55 : void 56 1543 : HeatStructureBase::addVariables() 57 : { 58 1543 : HeatStructureInterface::addVariables(); 59 1543 : } 60 : 61 : void 62 1543 : HeatStructureBase::addMooseObjects() 63 : { 64 1543 : HeatStructureInterface::addMooseObjects(); 65 : 66 3086 : if (isParamValid("materials")) 67 : { 68 36 : _hc_model->addMaterials(); 69 : 70 108 : for (unsigned int i = 0; i < _n_regions; i++) 71 : { 72 : const SolidMaterialProperties & smp = 73 72 : getTHMProblem().getUserObject<SolidMaterialProperties>(_material_names[i]); 74 : 75 72 : Component * comp = (_parent != nullptr) ? _parent : this; 76 : // if the values were given as constant, allow them to be controlled 77 72 : const ConstantFunction * k_fn = dynamic_cast<const ConstantFunction *>(&smp.getKFunction()); 78 72 : if (k_fn != nullptr) 79 144 : comp->connectObject(k_fn->parameters(), k_fn->name(), "k", "value"); 80 : 81 72 : const ConstantFunction * cp_fn = dynamic_cast<const ConstantFunction *>(&smp.getCpFunction()); 82 72 : if (cp_fn != nullptr) 83 144 : comp->connectObject(cp_fn->parameters(), cp_fn->name(), "cp", "value"); 84 : 85 : const ConstantFunction * rho_fn = 86 72 : dynamic_cast<const ConstantFunction *>(&smp.getRhoFunction()); 87 72 : if (rho_fn != nullptr) 88 144 : comp->connectObject(rho_fn->parameters(), rho_fn->name(), "rho", "value"); 89 : } 90 : } 91 : 92 3086 : if (isParamValid("solid_properties")) 93 : { 94 2740 : const auto sp_names = getParam<std::vector<UserObjectName>>("solid_properties"); 95 2740 : const auto T_ref = getParam<std::vector<Real>>("solid_properties_T_ref"); 96 3324 : for (unsigned int i = 0; i < sp_names.size(); i++) 97 1954 : addConstantDensitySolidPropertiesMaterial(sp_names[i], T_ref[i], i); 98 1370 : } 99 1543 : } 100 : 101 : void 102 1954 : HeatStructureBase::addConstantDensitySolidPropertiesMaterial(const UserObjectName & sp_name, 103 : const Real & T_ref, 104 : unsigned int i_region) const 105 : { 106 1954 : const auto blocks = getSubdomainNames(); 107 1954 : const auto region_names = getNames(); 108 : 109 1954 : const std::string class_name = "ADConstantDensityThermalSolidPropertiesMaterial"; 110 1954 : InputParameters params = _factory.getValidParams(class_name); 111 5862 : params.set<std::vector<SubdomainName>>("block") = {blocks[i_region]}; 112 5862 : params.set<std::vector<VariableName>>("temperature") = {HeatConductionModel::TEMPERATURE}; 113 1954 : params.set<UserObjectName>("sp") = sp_name; 114 1954 : params.set<Real>("T_ref") = T_ref; 115 3908 : getTHMProblem().addMaterial( 116 1954 : class_name, genName(name(), class_name, region_names[i_region]), params); 117 3908 : }