www.mooseframework.org
HeatConductionMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 #include "Function.h"
10 
11 #include "libmesh/quadrature.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<Material>();
18 
19  params.addCoupledVar("temp", "Coupled Temperature");
20 
21  params.addParam<Real>("thermal_conductivity", "The thermal conductivity value");
22  params.addParam<FunctionName>("thermal_conductivity_temperature_function",
23  "",
24  "Thermal conductivity as a function of temperature.");
25 
26  params.addParam<Real>("specific_heat", "The specific heat value");
27  params.addParam<FunctionName>(
28  "specific_heat_temperature_function", "", "Specific heat as a function of temperature.");
29  params.addClassDescription("General-purpose material model for heat conduction");
30 
31  return params;
32 }
33 
34 HeatConductionMaterial::HeatConductionMaterial(const InputParameters & parameters)
35  : Material(parameters),
36 
37  _has_temp(isCoupled("temp")),
38  _temperature(_has_temp ? coupledValue("temp") : _zero),
39  _my_thermal_conductivity(
40  isParamValid("thermal_conductivity") ? getParam<Real>("thermal_conductivity") : 0),
41  _my_specific_heat(isParamValid("specific_heat") ? getParam<Real>("specific_heat") : 0),
42 
43  _thermal_conductivity(declareProperty<Real>("thermal_conductivity")),
44  _thermal_conductivity_dT(declareProperty<Real>("thermal_conductivity_dT")),
45  _thermal_conductivity_temperature_function(
46  getParam<FunctionName>("thermal_conductivity_temperature_function") != ""
47  ? &getFunction("thermal_conductivity_temperature_function")
48  : NULL),
49 
50  _specific_heat(declareProperty<Real>("specific_heat")),
51  _specific_heat_temperature_function(
52  getParam<FunctionName>("specific_heat_temperature_function") != ""
53  ? &getFunction("specific_heat_temperature_function")
54  : NULL)
55 {
57  {
58  mooseError("Must couple with temperature if using thermal conductivity function");
59  }
60  if (isParamValid("thermal_conductivity") && _thermal_conductivity_temperature_function)
61  {
62  mooseError(
63  "Cannot define both thermal conductivity and thermal conductivity temperature function");
64  }
66  {
67  mooseError("Must couple with temperature if using specific heat function");
68  }
69  if (isParamValid("specific_heat") && _specific_heat_temperature_function)
70  {
71  mooseError("Cannot define both specific heat and specific heat temperature function");
72  }
73 }
74 
75 void
77 {
78  for (unsigned int qp(0); qp < _qrule->n_points(); ++qp)
79  {
80  Real qp_temperature = 0;
81  if (_has_temp)
82  {
83  qp_temperature = _temperature[qp];
84  if (_temperature[qp] < 0)
85  {
86  std::stringstream msg;
87  msg << "WARNING: In HeatConductionMaterial: negative temperature!\n"
88  << "\tResetting to zero.\n"
89  << "\t_qp: " << qp << "\n"
90  << "\ttemp: " << _temperature[qp] << "\n"
91  << "\telem: " << _current_elem->id() << "\n"
92  << "\tproc: " << processor_id() << "\n";
93  mooseWarning(msg.str());
94  qp_temperature = 0;
95  }
96  }
98  {
99  Point p;
101  _thermal_conductivity_temperature_function->value(qp_temperature, p);
103  _thermal_conductivity_temperature_function->timeDerivative(qp_temperature, p);
104  }
105  else
106  {
108  _thermal_conductivity_dT[qp] = 0;
109  }
110 
112  {
113  Point p;
114  _specific_heat[qp] = _specific_heat_temperature_function->value(qp_temperature, p);
115  }
116  else
117  {
119  }
120  }
121 }
MaterialProperty< Real > & _thermal_conductivity_dT
Function * _thermal_conductivity_temperature_function
MaterialProperty< Real > & _thermal_conductivity
InputParameters validParams< HeatConductionMaterial >()
Function * _specific_heat_temperature_function
const VariableValue & _temperature
MaterialProperty< Real > & _specific_heat
HeatConductionMaterial(const InputParameters &parameters)