https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeatConductionMaterial.C
Go to the documentation of this file.
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
11#include "Function.h"
12
13#include "libmesh/quadrature.h"
14
17
18template <bool is_ad>
21{
23
24 params.addCoupledVar("temp", "Coupled Temperature");
25 params.deprecateCoupledVar("temp", "temperature", "01/12/2027");
26
27 params.addParam<Real>("thermal_conductivity", "The thermal conductivity value");
28 params.addParam<FunctionName>("thermal_conductivity_temperature_function",
29 "",
30 "Thermal conductivity as a function of temperature.");
31 params.addParam<Real>("min_T",
32 "Minimum allowable value for temperature for evaluating properties "
33 "when provided by functions");
34
35 params.addParam<Real>("specific_heat", "The specific heat value");
36 params.addParam<FunctionName>(
37 "specific_heat_temperature_function", "", "Specific heat as a function of temperature.");
38 params.addClassDescription("General-purpose material model for heat conduction");
39
40 return params;
41}
42
43template <bool is_ad>
45 : Material(parameters),
46 _has_temp(isCoupled("temp")),
47 _temperature(_has_temp ? coupledGenericValue<is_ad>("temp") : genericZeroValue<is_ad>()),
48 _my_thermal_conductivity(
49 isParamValid("thermal_conductivity") ? getParam<Real>("thermal_conductivity") : 0),
50 _my_specific_heat(isParamValid("specific_heat") ? getParam<Real>("specific_heat") : 0),
51
52 _thermal_conductivity(declareGenericProperty<Real, is_ad>("thermal_conductivity")),
53 _thermal_conductivity_dT(declareProperty<Real>("thermal_conductivity_dT")),
54 _thermal_conductivity_temperature_function(
55 getParam<FunctionName>("thermal_conductivity_temperature_function") != ""
56 ? &getFunction("thermal_conductivity_temperature_function")
57 : nullptr),
58
59 _specific_heat(declareGenericProperty<Real, is_ad>("specific_heat")),
60 _specific_heat_temperature_function(
61 getParam<FunctionName>("specific_heat_temperature_function") != ""
62 ? &getFunction("specific_heat_temperature_function")
63 : nullptr),
64 _specific_heat_dT(is_ad && !_specific_heat_temperature_function
65 ? nullptr
66 : &declareGenericProperty<Real, is_ad>("specific_heat_dT")),
67 _min_T(isParamValid("min_T") ? &getParam<Real>("min_T") : nullptr)
68{
70 paramError("thermal_conductivity_temperature_function",
71 "Must couple with temperature if using thermal conductivity function");
72
73 if (isParamValid("thermal_conductivity") && _thermal_conductivity_temperature_function)
75 "Cannot define both thermal conductivity and thermal conductivity temperature function");
76
78 paramError("specific_heat_temperature_function",
79 "Must couple with temperature if using specific heat function");
80
82 mooseError("Cannot define both specific heat and specific heat temperature function");
83}
84
85template <bool is_ad>
86void
88{
89 auto qp_temperature = _temperature[_qp];
90
91 if (_has_temp && _min_T)
92 {
93 if (_temperature[_qp] < *_min_T)
94 {
95 flagSolutionWarning("Temperature below specified minimum (" + std::to_string(*_min_T) +
96 "). min_T will be used instead.");
97 qp_temperature = *_min_T;
98 }
99 }
100
101 if (_thermal_conductivity_temperature_function)
102 {
103 _thermal_conductivity[_qp] = _thermal_conductivity_temperature_function->value(qp_temperature);
104 _thermal_conductivity_dT[_qp] = _thermal_conductivity_temperature_function->timeDerivative(
105 MetaPhysicL::raw_value(qp_temperature));
106 }
107 else
108 {
109 _thermal_conductivity[_qp] = _my_thermal_conductivity;
110 _thermal_conductivity_dT[_qp] = 0;
111 }
112
113 if (_specific_heat_temperature_function)
114 {
115 _specific_heat[_qp] = _specific_heat_temperature_function->value(qp_temperature);
116 if (_specific_heat_dT)
117 (*_specific_heat_dT)[_qp] = _specific_heat_temperature_function->timeDerivative(
118 MetaPhysicL::raw_value(qp_temperature));
119 }
120 else
121 _specific_heat[_qp] = _my_specific_heat;
122}
123
registerMooseObject("HeatTransferApp", HeatConductionMaterial)
Simple material with properties set as constants or by functions.
static InputParameters validParams()
const Function *const _thermal_conductivity_temperature_function
HeatConductionMaterialTempl(const InputParameters &parameters)
virtual void computeQpProperties() override
const Function *const _specific_heat_temperature_function
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
auto raw_value(const Eigen::Map< T > &in)