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