www.mooseframework.org
AnisoHeatConduction.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 
8 #include "AnisoHeatConduction.h"
9 #include "MooseMesh.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Kernel>();
16  params.set<bool>("use_displaced_mesh") = true;
17  return params;
18 }
19 
20 AnisoHeatConduction::AnisoHeatConduction(const InputParameters & parameters)
21  : Kernel(parameters), _dim(_subproblem.mesh().dimension())
22 {
23  _k_i[0] = _k_i[1] = _k_i[2] = NULL;
24  _k_i_dT[0] = _k_i_dT[1] = _k_i_dT[2] = NULL;
25 
26  if (hasMaterialProperty<Real>("thermal_conductivity_x"))
27  _k_i[0] = &getMaterialProperty<Real>("thermal_conductivity_x");
28 
29  if (hasMaterialProperty<Real>("thermal_conductivity_x_dT"))
30  _k_i_dT[0] = &getMaterialProperty<Real>("thermal_conductivity_x_dT");
31 
32  if (hasMaterialProperty<Real>("thermal_conductivity_y"))
33  _k_i[1] = &getMaterialProperty<Real>("thermal_conductivity_y");
34 
35  if (hasMaterialProperty<Real>("thermal_conductivity_y_dT"))
36  _k_i_dT[1] = &getMaterialProperty<Real>("thermal_conductivity_y_dT");
37 
38  if (hasMaterialProperty<Real>("thermal_conductivity_z"))
39  _k_i[2] = &getMaterialProperty<Real>("thermal_conductivity_z");
40 
41  if (hasMaterialProperty<Real>("thermal_conductivity_z_dT"))
42  _k_i_dT[2] = &getMaterialProperty<Real>("thermal_conductivity_z_dT");
43 
44  if (!_k_i[0])
45  mooseError("No thermal conductivity was defined");
46 
47  if (!_k_i[0] && _k_i[1])
48  mooseError("Cannot define y conductivity but not x");
49 
50  if (_k_i[2] && (!_k_i[0] || !_k_i[1]))
51  mooseError("Cannot define z conductivty but not x and y");
52 
53  if (_dim == 2 && !_k_i[1])
54  mooseError("Must define x and y thermal conductivities for 2D");
55 
56  if (_dim == 3 && (!_k_i[1] || !_k_i[2]))
57  mooseError("Must define x, y, and z thermal conductivities for 3D");
58 
59  if (_dim == 2 && !(_k_i_dT[0] && _k_i_dT[1]))
60  mooseError("Must define k_x_dT and k_y_dT for 2D");
61 
62  if (_dim == 3 && !(_k_i_dT[0] && _k_i_dT[1] && _k_i_dT[2]))
63  mooseError("Must define k_x_dT, k_y_dT, and k_z_dT for 3D");
64 }
65 
66 Real
68 {
69  Real r(0);
70  // r = _k[_qp]*Diffusion::computeQpResidual();
71  // if (!libmesh_isnan(r))
72  // {
73  // }
74  // else
75  // {
76  // Moose::err << "NaN found at " << __LINE__ << " in " << __FILE__ << "!\n"
77  // << "Processor: " << libMesh::processor_id() << "\n"
78  // << "_k[_qp]: " << _k[_qp] << "\n"
79  // << "Diffusion resid: " << Diffusion::computeQpResidual() << "\n"
80  // << "Elem: " << _current_elem->id() << "\n"
81  // << "Qp: " << _qp << "\n"
82  // << "Qpoint: " << _q_point[_qp] << "\n"
83  // << std::endl;
84  // }
85  // return r;
86  for (unsigned i(0); i < _dim; ++i)
87  {
88  r += _grad_test[_i][_qp](i) * (*_k_i[i])[_qp] * _grad_u[_qp](i);
89  }
90  return r;
91 }
92 
93 Real
95 {
96  Real jac(0);
97  for (unsigned i(0); i < _dim; ++i)
98  {
99  jac += _grad_test[_i][_qp](i) * (*_k_i[i])[_qp] * _grad_phi[_j][_qp](i);
100  if (_k_i_dT[i])
101  {
102  jac += (*_k_i_dT[i])[_qp] * _phi[_j][_qp] *
103  (_grad_test[_i][_qp](i) * (*_k_i[i])[_qp] * _grad_u[_qp](i));
104  }
105  }
106  return jac;
107 }
AnisoHeatConduction(const InputParameters &parameters)
InputParameters validParams< AnisoHeatConduction >()
virtual Real computeQpJacobian()
const MaterialProperty< Real > * _k_i_dT[3]
virtual Real computeQpResidual()
const MaterialProperty< Real > * _k_i[3]