Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 : // Navier-Stokes includes 11 : #include "NSTemperatureL2.h" 12 : #include "NS.h" 13 : 14 : // MOOSE includes 15 : #include "MooseMesh.h" 16 : 17 : registerMooseObject("NavierStokesApp", NSTemperatureL2); 18 : 19 : InputParameters 20 0 : NSTemperatureL2::validParams() 21 : { 22 0 : InputParameters params = Kernel::validParams(); 23 0 : params.addClassDescription( 24 : "This class was originally used to solve for the temperature using an L2-projection."); 25 0 : params.addRequiredCoupledVar(NS::velocity_x, "x-direction velocity component"); 26 0 : params.addCoupledVar(NS::velocity_y, "y-direction velocity component"); // only reqiured in >= 2D 27 0 : params.addCoupledVar(NS::velocity_z, "z-direction velocity component"); // only required in 3D 28 0 : params.addRequiredCoupledVar("rhoe", "Total energy"); 29 0 : params.addRequiredCoupledVar(NS::density, "Density"); 30 0 : return params; 31 0 : } 32 : 33 0 : NSTemperatureL2::NSTemperatureL2(const InputParameters & parameters) 34 : : Kernel(parameters), 35 0 : _rho_var(coupled(NS::density)), 36 0 : _rho(coupledValue(NS::density)), 37 0 : _rhoe_var(coupled("rhoe")), 38 0 : _rhoe(coupledValue("rhoe")), 39 0 : _u_vel_var(coupled(NS::velocity_x)), 40 0 : _u_vel(coupledValue(NS::velocity_x)), 41 0 : _v_vel_var(_mesh.dimension() >= 2 ? coupled(NS::velocity_y) : libMesh::invalid_uint), 42 0 : _v_vel(_mesh.dimension() >= 2 ? coupledValue(NS::velocity_y) : _zero), 43 0 : _w_vel_var(_mesh.dimension() == 3 ? coupled(NS::velocity_z) : libMesh::invalid_uint), 44 0 : _w_vel(_mesh.dimension() == 3 ? coupledValue(NS::velocity_z) : _zero), 45 0 : _c_v(getMaterialProperty<Real>("c_v")) 46 : { 47 0 : } 48 : 49 : Real 50 0 : NSTemperatureL2::computeQpResidual() 51 : { 52 0 : Real value = 1.0 / _c_v[_qp]; 53 : 54 0 : const Real et = _rhoe[_qp] / _rho[_qp]; 55 0 : const RealVectorValue vec(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]); 56 : 57 0 : value *= et - ((vec * vec) / 2.0); 58 : 59 : // L2-projection 60 0 : return (_u[_qp] - value) * _test[_i][_qp]; 61 : } 62 : 63 : Real 64 0 : NSTemperatureL2::computeQpJacobian() 65 : { 66 0 : return _phi[_j][_qp] * _test[_i][_qp]; 67 : } 68 : 69 : Real 70 0 : NSTemperatureL2::computeQpOffDiagJacobian(unsigned int jvar) 71 : { 72 0 : if (jvar == _rho_var) 73 : { 74 0 : const Real et = (_rhoe[_qp] / (-_rho[_qp] * _rho[_qp])) * _phi[_j][_qp]; 75 0 : Real value = et / _c_v[_qp]; 76 : 77 0 : return -value * _test[_i][_qp]; 78 : } 79 0 : else if (jvar == _rhoe_var) 80 : { 81 0 : const Real et = _phi[_j][_qp] / _rho[_qp]; 82 0 : Real value = et / _c_v[_qp]; 83 : 84 0 : return -value * _test[_i][_qp]; 85 : } 86 : 87 : return 0.0; 88 : }