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 "AnisoHeatConductionMaterial.h" 11 : #include "Function.h" 12 : #include "ConstantFunction.h" 13 : #include "MooseMesh.h" 14 : #include "RankTwoTensorImplementation.h" 15 : 16 : #include "libmesh/quadrature.h" 17 : 18 : registerMooseObject("HeatTransferApp", AnisoHeatConductionMaterial); 19 : registerMooseObject("HeatTransferApp", ADAnisoHeatConductionMaterial); 20 : 21 : template <bool is_ad> 22 : InputParameters 23 210 : AnisoHeatConductionMaterialTempl<is_ad>::validParams() 24 : { 25 210 : InputParameters params = Material::validParams(); 26 : 27 420 : params.addCoupledVar("temperature", "Coupled variable for temperature."); 28 420 : params.addParam<Real>( 29 420 : "reference_temperature", 293.0, "Reference temperature for thermal conductivity in Kelvin."); 30 420 : params.addParam<std::string>("base_name", "Material property base name."); 31 420 : params.addRequiredParam<std::vector<Real>>("thermal_conductivity", 32 : "The thermal conductivity tensor values"); 33 420 : params.addParam<FunctionName>( 34 : "thermal_conductivity_temperature_coefficient_function", 35 : "", 36 : "Temperature coefficient for thermal conductivity as a function of temperature."); 37 420 : params.addRequiredParam<FunctionName>("specific_heat", 38 : "Specific heat as a function of temperature."); 39 210 : params.addClassDescription("General-purpose material model for anisotropic heat conduction"); 40 210 : return params; 41 0 : } 42 : 43 : template <bool is_ad> 44 162 : AnisoHeatConductionMaterialTempl<is_ad>::AnisoHeatConductionMaterialTempl( 45 : const InputParameters & parameters) 46 : : DerivativeMaterialInterface<Material>(parameters), 47 162 : _dim(_subproblem.mesh().dimension()), 48 324 : _ref_temp(getParam<Real>("reference_temperature")), 49 : 50 162 : _has_temp(isCoupled("temperature")), 51 162 : _T(coupledGenericValue<is_ad>("temperature")), 52 162 : _T_var(coupled("temperature")), 53 162 : _T_name(coupledName("temperature", 0)), 54 324 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 55 : 56 324 : _user_provided_thermal_conductivity(getParam<std::vector<Real>>("thermal_conductivity")), 57 162 : _thermal_conductivity( 58 162 : declareGenericProperty<RankTwoTensor, is_ad>(_base_name + "thermal_conductivity")), 59 162 : _dthermal_conductivity_dT( 60 324 : declarePropertyDerivative<RankTwoTensor>(_base_name + "thermal_conductivity", _T_name)), 61 162 : _thermal_conductivity_temperature_coefficient_function( 62 324 : getParam<FunctionName>("thermal_conductivity_temperature_coefficient_function") != "" 63 162 : ? &getFunction("thermal_conductivity_temperature_coefficient_function") 64 : : nullptr), 65 : 66 324 : _specific_heat(declareGenericProperty<Real, is_ad>(_base_name + "specific_heat")), 67 162 : _dspecific_heat_dT(declarePropertyDerivative<Real>(_base_name + "specific_heat", _T_name)), 68 162 : _specific_heat_function(&getFunction("specific_heat")), 69 162 : _ad_q_point(is_ad ? &_assembly.adQPoints() : nullptr) 70 : { 71 162 : } 72 : 73 : template <bool is_ad> 74 : void 75 0 : AnisoHeatConductionMaterialTempl<is_ad>::initQpStatefulProperties() 76 : { 77 0 : _thermal_conductivity[_qp] = _user_provided_thermal_conductivity; 78 0 : DerivativeMaterialInterface::initQpStatefulProperties(); 79 0 : } 80 : 81 : template <> 82 : auto 83 0 : AnisoHeatConductionMaterialTempl<true>::genericQPoints() 84 : { 85 0 : return (*_ad_q_point)[_qp]; 86 : } 87 : 88 : template <> 89 : auto 90 70048 : AnisoHeatConductionMaterialTempl<false>::genericQPoints() 91 : { 92 70048 : return _q_point[_qp]; 93 : } 94 : 95 : template <bool is_ad> 96 : void 97 70048 : AnisoHeatConductionMaterialTempl<is_ad>::computeQpProperties() 98 : { 99 70048 : const auto & temp_qp = _T[_qp]; 100 70048 : const auto & p = genericQPoints(); 101 : 102 70048 : if (_thermal_conductivity_temperature_coefficient_function) 103 : { 104 : 105 0 : _thermal_conductivity[_qp] = 106 : _user_provided_thermal_conductivity * 107 0 : (1.0 + _thermal_conductivity_temperature_coefficient_function->value(temp_qp, p) * 108 0 : (temp_qp - _ref_temp)); 109 0 : _dthermal_conductivity_dT[_qp] = 110 : _user_provided_thermal_conductivity * 111 0 : _thermal_conductivity_temperature_coefficient_function->timeDerivative( 112 0 : MetaPhysicL::raw_value(temp_qp), _q_point[_qp]) * 113 0 : MetaPhysicL::raw_value(temp_qp - _ref_temp); 114 : } 115 : else 116 70048 : _thermal_conductivity[_qp] = _user_provided_thermal_conductivity; 117 : 118 70048 : _specific_heat[_qp] = _specific_heat_function->value(temp_qp, p); 119 70048 : _dspecific_heat_dT[_qp] = 120 70048 : _specific_heat_function->timeDerivative(MetaPhysicL::raw_value(temp_qp), _q_point[_qp]); 121 70048 : } 122 : 123 : template class AnisoHeatConductionMaterialTempl<false>; 124 : template class AnisoHeatConductionMaterialTempl<true>;