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