https://mooseframework.inl.gov
NSThermalBC.C
Go to the documentation of this file.
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
16 
17 registerMooseObject("NavierStokesApp", NSThermalBC);
18 
21 {
23  params.addClassDescription("NS thermal BC.");
24  params.addRequiredCoupledVar(NS::density, "density");
25  params.addRequiredParam<Real>("initial", "Initial temperature");
26  params.addRequiredParam<Real>("final", "Final temperature");
27  params.addRequiredParam<Real>("duration",
28  "Time over which temperature ramps up from initial to final");
29  params.addRequiredParam<UserObjectName>("fluid_properties",
30  "The name of the user object for fluid properties");
31  return params;
32 }
33 
35  : NodalBC(parameters),
36  _rho_var(coupled(NS::density)),
37  _rho(coupledValue(NS::density)),
38  _initial(getParam<Real>("initial")),
39  _final(getParam<Real>("final")),
40  _duration(getParam<Real>("duration")),
41  _fp(getUserObject<IdealGasFluidProperties>("fluid_properties"))
42 {
43 }
44 
45 Real
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  if (_t < _duration)
54  value = _initial + (_final - _initial) * std::sin((0.5 * libMesh::pi) * _t / _duration);
55  else
56  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  return _u[_qp] - (_rho[_qp] * _fp.cv() * value);
74 }
registerMooseObject("NavierStokesApp", NSThermalBC)
Real _initial
Definition: NSThermalBC.h:32
virtual Real computeQpResidual()
Definition: NSThermalBC.C:46
static const std::string density
Definition: NS.h:33
Real _duration
Definition: NSThermalBC.h:34
const unsigned int _qp
void addRequiredParam(const std::string &name, const std::string &doc_string)
Real & _t
virtual const OutputTools< Real >::VariableValue & value()
const VariableValue & _rho
Definition: NSThermalBC.h:30
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const IdealGasFluidProperties & _fp
Definition: NSThermalBC.h:37
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Definition: NSThermalBC.C:20
Ideal gas fluid properties Default parameters are for air at atmospheric pressure and temperature...
static InputParameters validParams()
NSThermalBC(const InputParameters &parameters)
Definition: NSThermalBC.C:34
const VariableValue & _u
const Real pi