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 "NSThermalBC.h" 12 : #include "NS.h" 13 : 14 : // FluidProperties includes 15 : #include "IdealGasFluidProperties.h" 16 : 17 : registerMooseObject("NavierStokesApp", NSThermalBC); 18 : 19 : InputParameters 20 0 : NSThermalBC::validParams() 21 : { 22 0 : InputParameters params = NodalBC::validParams(); 23 0 : params.addClassDescription("NS thermal BC."); 24 0 : params.addRequiredCoupledVar(NS::density, "density"); 25 0 : params.addRequiredParam<Real>("initial", "Initial temperature"); 26 0 : params.addRequiredParam<Real>("final", "Final temperature"); 27 0 : params.addRequiredParam<Real>("duration", 28 : "Time over which temperature ramps up from initial to final"); 29 0 : params.addRequiredParam<UserObjectName>("fluid_properties", 30 : "The name of the user object for fluid properties"); 31 0 : return params; 32 0 : } 33 : 34 0 : NSThermalBC::NSThermalBC(const InputParameters & parameters) 35 : : NodalBC(parameters), 36 0 : _rho_var(coupled(NS::density)), 37 0 : _rho(coupledValue(NS::density)), 38 0 : _initial(getParam<Real>("initial")), 39 0 : _final(getParam<Real>("final")), 40 0 : _duration(getParam<Real>("duration")), 41 0 : _fp(getUserObject<IdealGasFluidProperties>("fluid_properties")) 42 : { 43 0 : } 44 : 45 : Real 46 0 : NSThermalBC::computeQpResidual() 47 : { 48 : Real value; 49 : 50 : // For constant temperature, set _initial = _final, or set _duration=0 and set _final. 51 : // 52 : // T(t) = T_i + (T_f - T_i) * sin (pi/2 * t/t_d) 53 0 : if (_t < _duration) 54 0 : value = _initial + (_final - _initial) * std::sin((0.5 * libMesh::pi) * _t / _duration); 55 : else 56 0 : value = _final; 57 : 58 : // For the total energy, the essential BC is: 59 : // rho*E = rho*(c_v*T + |u|^2/2) 60 : // 61 : // or, in residual form, (In general, this BC is coupled to the velocity variables.) 62 : // rho*E - rho*(c_v*T + |u|^2/2) = 0 63 : // 64 : // ***at a no-slip wall*** this further reduces to (no coupling to velocity variables): 65 : // rho*E - rho*cv*T = 0 66 : 67 : // std::ios_base::fmtflags flags = Moose::out.flags(); 68 : // Moose::out << std::scientific << std::setprecision(16); 69 : // Moose::out << "rho*E =" << _u[_qp] << std::endl; 70 : // Moose::out << "(_p[_qp] * _c_v[_qp] * value)=" << (_p[_qp] * _c_v[_qp] * value) << std::endl; 71 : // //Moose::out << "_c_v[_qp] =" << _c_v[_qp] << std::endl; 72 : // Moose::out.flags(flags); 73 0 : return _u[_qp] - (_rho[_qp] * _fp.cv() * value); 74 : }