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