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 
18 
19 InputParameters
21 {
22  InputParameters params = Material::validParams();
23 
24  params.addCoupledVar("temp", "Coupled Temperature");
25 
26  params.addParam<Real>("thermal_conductivity", "The thermal conductivity value");
27  params.addParam<FunctionName>("thermal_conductivity_temperature_function",
28  "",
29  "Thermal conductivity as a function of temperature.");
30 
31  params.addParam<Real>("specific_heat", "The specific heat value");
32  params.addParam<FunctionName>(
33  "specific_heat_temperature_function", "", "Specific heat as a function of temperature.");
34  params.addClassDescription("General-purpose material model for heat conduction");
35 
36  return params;
37 }
38 
39 HeatConductionMaterial::HeatConductionMaterial(const InputParameters & parameters)
40  : Material(parameters),
41 
42  _has_temp(isCoupled("temp")),
43  _temperature(_has_temp ? coupledValue("temp") : _zero),
44  _my_thermal_conductivity(
45  isParamValid("thermal_conductivity") ? getParam<Real>("thermal_conductivity") : 0),
46  _my_specific_heat(isParamValid("specific_heat") ? getParam<Real>("specific_heat") : 0),
47 
48  _thermal_conductivity(declareProperty<Real>("thermal_conductivity")),
49  _thermal_conductivity_dT(declareProperty<Real>("thermal_conductivity_dT")),
50  _thermal_conductivity_temperature_function(
51  getParam<FunctionName>("thermal_conductivity_temperature_function") != ""
52  ? &getFunction("thermal_conductivity_temperature_function")
53  : NULL),
54 
55  _specific_heat(declareProperty<Real>("specific_heat")),
56  _specific_heat_temperature_function(
57  getParam<FunctionName>("specific_heat_temperature_function") != ""
58  ? &getFunction("specific_heat_temperature_function")
59  : NULL)
60 {
62  {
63  mooseError("Must couple with temperature if using thermal conductivity function");
64  }
65  if (isParamValid("thermal_conductivity") && _thermal_conductivity_temperature_function)
66  {
67  mooseError(
68  "Cannot define both thermal conductivity and thermal conductivity temperature function");
69  }
71  {
72  mooseError("Must couple with temperature if using specific heat function");
73  }
74  if (isParamValid("specific_heat") && _specific_heat_temperature_function)
75  {
76  mooseError("Cannot define both specific heat and specific heat temperature function");
77  }
78 }
79 
80 void
82 {
83  for (unsigned int qp(0); qp < _qrule->n_points(); ++qp)
84  {
85  Real qp_temperature = 0;
86  if (_has_temp)
87  {
88  qp_temperature = _temperature[qp];
89  if (_temperature[qp] < 0)
90  {
91  std::stringstream msg;
92  msg << "WARNING: In HeatConductionMaterial: negative temperature!\n"
93  << "\tResetting to zero.\n"
94  << "\t_qp: " << qp << "\n"
95  << "\ttemp: " << _temperature[qp] << "\n"
96  << "\telem: " << _current_elem->id() << "\n"
97  << "\tproc: " << processor_id() << "\n";
98  mooseWarning(msg.str());
99  qp_temperature = 0;
100  }
101  }
103  {
104  Point p;
106  _thermal_conductivity_temperature_function->value(qp_temperature, p);
108  _thermal_conductivity_temperature_function->timeDerivative(qp_temperature, p);
109  }
110  else
111  {
113  _thermal_conductivity_dT[qp] = 0;
114  }
115 
117  {
118  Point p;
119  _specific_heat[qp] = _specific_heat_temperature_function->value(qp_temperature, p);
120  }
121  else
122  {
124  }
125  }
126 }
defineLegacyParams
defineLegacyParams(HeatConductionMaterial)
HeatConductionMaterial::_my_thermal_conductivity
const Real _my_thermal_conductivity
Definition: HeatConductionMaterial.h:37
HeatConductionMaterial::_has_temp
const bool _has_temp
Definition: HeatConductionMaterial.h:34
HeatConductionMaterial::HeatConductionMaterial
HeatConductionMaterial(const InputParameters &parameters)
Definition: HeatConductionMaterial.C:39
HeatConductionMaterial::_thermal_conductivity
MaterialProperty< Real > & _thermal_conductivity
Definition: HeatConductionMaterial.h:40
HeatConductionMaterial::_specific_heat_temperature_function
const Function * _specific_heat_temperature_function
Definition: HeatConductionMaterial.h:45
HeatConductionMaterial::_specific_heat
MaterialProperty< Real > & _specific_heat
Definition: HeatConductionMaterial.h:44
HeatConductionMaterial::_thermal_conductivity_temperature_function
const Function * _thermal_conductivity_temperature_function
Definition: HeatConductionMaterial.h:42
registerMooseObject
registerMooseObject("HeatConductionApp", HeatConductionMaterial)
HeatConductionMaterial
Simple material with constant properties.
Definition: HeatConductionMaterial.h:24
HeatConductionMaterial::computeProperties
virtual void computeProperties()
Definition: HeatConductionMaterial.C:81
validParams
InputParameters validParams()
HeatConductionMaterial.h
HeatConductionMaterial::_my_specific_heat
const Real _my_specific_heat
Definition: HeatConductionMaterial.h:38
HeatConductionMaterial::_thermal_conductivity_dT
MaterialProperty< Real > & _thermal_conductivity_dT
Definition: HeatConductionMaterial.h:41
HeatConductionMaterial::validParams
static InputParameters validParams()
Definition: HeatConductionMaterial.C:20
HeatConductionMaterial::_temperature
const VariableValue & _temperature
Definition: HeatConductionMaterial.h:35