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