www.mooseframework.org
INSTemperature.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 "INSTemperature.h"
11 #include "MooseMesh.h"
12 
13 registerMooseObject("NavierStokesApp", INSTemperature);
14 
17 {
19 
20  params.addClassDescription("This class computes the residual and Jacobian contributions for the "
21  "incompressible Navier-Stokes temperature (energy) equation.");
22  // Coupled variables
23  params.addRequiredCoupledVar("u", "x-velocity");
24  params.addCoupledVar("v", "y-velocity"); // only required in 2D and 3D
25  params.addCoupledVar("w", "z-velocity"); // only required in 3D
26 
27  // Optional parameters
28  params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
29  params.addParam<MaterialPropertyName>("k_name", "k", "thermal conductivity name");
30  params.addParam<MaterialPropertyName>("cp_name", "cp", "specific heat name");
31 
32  return params;
33 }
34 
36  : Kernel(parameters),
37 
38  // Coupled variables
39  _u_vel(coupledValue("u")),
40  _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
41  _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero),
42 
43  // Variable numberings
44  _u_vel_var_number(coupled("u")),
45  _v_vel_var_number(_mesh.dimension() >= 2 ? coupled("v") : libMesh::invalid_uint),
46  _w_vel_var_number(_mesh.dimension() == 3 ? coupled("w") : libMesh::invalid_uint),
47 
48  // Material Properties
49  _rho(getMaterialProperty<Real>("rho_name")),
50  _k(getMaterialProperty<Real>("k_name")),
51  _cp(getMaterialProperty<Real>("cp_name"))
52 {
53 }
54 
55 Real
57 {
58  // The convection part, rho * cp u.grad(T) * v.
59  // Note: _u is the temperature variable, _grad_u is its gradient.
60  Real convective_part = _rho[_qp] * _cp[_qp] *
61  (_u_vel[_qp] * _grad_u[_qp](0) + _v_vel[_qp] * _grad_u[_qp](1) +
62  _w_vel[_qp] * _grad_u[_qp](2)) *
63  _test[_i][_qp];
64 
65  // Thermal conduction part, k * grad(T) * grad(v)
66  Real conduction_part = _k[_qp] * _grad_u[_qp] * _grad_test[_i][_qp];
67 
68  return convective_part + conduction_part;
69 }
70 
71 Real
73 {
75 
76  Real convective_part = _rho[_qp] * _cp[_qp] * (U * _grad_phi[_j][_qp]) * _test[_i][_qp];
77  Real conduction_part = _k[_qp] * (_grad_phi[_j][_qp] * _grad_test[_i][_qp]);
78 
79  return convective_part + conduction_part;
80 }
81 
82 Real
84 {
85  if (jvar == _u_vel_var_number)
86  {
87  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](0) * _test[_i][_qp];
88  return convective_part;
89  }
90 
91  else if (jvar == _v_vel_var_number)
92  {
93  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](1) * _test[_i][_qp];
94  return convective_part;
95  }
96 
97  else if (jvar == _w_vel_var_number)
98  {
99  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](2) * _test[_i][_qp];
100  return convective_part;
101  }
102  else
103  return 0;
104 }
const VariableValue & _v_vel
virtual Real computeQpJacobian()
const VariableGradient & _grad_u
INSTemperature(const InputParameters &parameters)
static InputParameters validParams()
const unsigned int invalid_uint
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const MaterialProperty< Real > & _rho
const VariablePhiGradient & _grad_phi
const VariableValue & _u_vel
virtual Real computeQpResidual()
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
unsigned _v_vel_var_number
const VariableValue & _w_vel
static InputParameters validParams()
const VariableTestValue & _test
unsigned int _i
unsigned _u_vel_var_number
unsigned _w_vel_var_number
void addCoupledVar(const std::string &name, const std::string &doc_string)
This class computes the residual and Jacobian contributions for the incompressible Navier-Stokes temp...
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
const MaterialProperty< Real > & _k
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableTestGradient & _grad_test
virtual Real computeQpOffDiagJacobian(unsigned jvar)
void addClassDescription(const std::string &doc_string)
registerMooseObject("NavierStokesApp", INSTemperature)
const VariablePhiValue & _phi
const MaterialProperty< Real > & _cp
unsigned int _qp