https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVTemperatureWallFunctionBC.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
11#include "NavierStokesMethods.h"
12
14
17{
19 params.addClassDescription("Computes the wall value of the turbulent thermal conductivity based "
20 "on turbulent temperature wall functions.");
21 params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
22 params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
23 params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
24 params.addRequiredParam<MooseFunctorName>(NS::density, "Density");
25 params.addRequiredParam<MooseFunctorName>(NS::mu, "Dynamic viscosity.");
26 params.addRequiredParam<MooseFunctorName>(NS::cp, "The specific heat at constant pressure.");
27 params.addParam<MooseFunctorName>(NS::k, "The thermal conductivity.");
28 params.addParam<MooseFunctorName>("Pr_t", 0.7, "The turbulent Prandtl number.");
29 params.addParam<MooseFunctorName>(NS::TKE, "The turbulent kinetic energy.");
30 params.addParam<Real>("C_mu", 0.09, "Coupled turbulent kinetic energy closure.");
31
32 MooseEnum wall_treatment("eq_newton eq_incremental eq_linearized neq", "neq");
33 params.addParam<MooseEnum>(
34 "wall_treatment", wall_treatment, "The method used for computing the wall functions");
35 return params;
36}
37
40 _dim(_subproblem.mesh().dimension()),
41 _u_var(getFunctor<Real>("u")),
42 _v_var(params.isParamValid("v") ? &(getFunctor<Real>("v")) : nullptr),
43 _w_var(params.isParamValid("w") ? &(getFunctor<Real>("w")) : nullptr),
44 _rho(getFunctor<Real>(NS::density)),
45 _mu(getFunctor<Real>(NS::mu)),
46 _cp(getFunctor<Real>(NS::cp)),
47 _k(getFunctor<Real>(NS::k)),
48 _Pr_t(getFunctor<Real>("Pr_t")),
49 _tke(getFunctor<Real>(NS::TKE)),
50 _C_mu(getParam<Real>("C_mu")),
51 _wall_treatment(getParam<MooseEnum>("wall_treatment").getEnum<NS::WallTreatmentEnum>())
52{
53}
54
55Real
57{
58 using std::abs, std::log, std::max, std::sqrt, std::pow, std::exp;
59
60 // Utility functions
61 const auto wall_dist = computeCellToFaceDistance();
62 const auto & elem = _current_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR
65 const auto re = makeElemArg(elem);
66 const auto state = determineState();
67 const auto mu = _mu(re, state);
68 const auto rho = _rho(re, state);
69 const auto cp = _cp(re, state);
70 const auto k = _k(re, state);
71 const auto Pr_t = _Pr_t(re, state);
72 const auto Pr = cp * mu / k;
73
74 // Get the velocity vector
75 RealVectorValue velocity(_u_var(re, state));
76 if (_v_var)
77 velocity(1) = (*_v_var)(re, state);
78 if (_w_var)
79 velocity(2) = (*_w_var)(re, state);
80
81 // Compute the velocity and direction of the velocity component that is parallel to the wall
82 const auto parallel_speed = NS::computeSpeed<Real>(
83 velocity - velocity * (_current_face_info->normal()) * (_current_face_info->normal()));
84
85 // Switch for determining the near wall quantities
86 // wall_treatment can be: "eq_newton eq_incremental eq_linearized neq"
87 Real y_plus = 0.0;
88 Real u_tau = 0.0;
89
91 {
92 // Full Newton-Raphson solve to find the wall quantities from the law of the wall
93 u_tau = NS::findUStar<Real>(mu, rho, parallel_speed, wall_dist);
94 y_plus = wall_dist * u_tau * rho / mu;
95 }
97 {
98 // Incremental solve on y_plus to get the near-wall quantities
99 y_plus = NS::findyPlus<Real>(mu, rho, std::max(parallel_speed, 1e-10), wall_dist);
100 u_tau = parallel_speed /
101 (log(max(NS::E_turb_constant * y_plus, 1.0 + 1e-4)) / NS::von_karman_constant);
102 }
104 {
105 // Linearized approximation to the wall function to find the near-wall quantities faster
106 const Real a_c = 1 / NS::von_karman_constant;
107 const Real b_c = 1 / NS::von_karman_constant *
108 (std::log(NS::E_turb_constant * std::max(wall_dist, 1.0) / mu) + 1.0);
109 const Real c_c = parallel_speed;
110
111 u_tau = (-b_c + std::sqrt(std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c);
112 y_plus = wall_dist * u_tau * rho / mu;
113 }
115 {
116 // Assign non-equilibrium wall function value
117 y_plus = std::pow(_C_mu, 0.25) * wall_dist * std::sqrt(_tke(re, state)) * rho / mu;
118 u_tau = parallel_speed /
119 (log(max(NS::E_turb_constant * y_plus, 1.0 + 1e-4)) / NS::von_karman_constant);
120 }
121 else
122 mooseAssert(false,
123 "For `LinearFVTemperatureWallFunctionBC` , wall treatment should not reach here");
124
125 Real T_plus = 0.0;
126 Real y_plus_thermal = 0.0;
127
128 // Compute thermal viscous layer thickness
129 y_plus_thermal = NS::findYplusThermal<Real>(Pr, Pr_t);
130
131 if (y_plus <= y_plus_thermal) // sub-laminar layer
132 {
133 T_plus = y_plus * Pr;
134 }
135 else // log-layer
136 {
137 const auto Pr_ratio = Pr / Pr_t;
138 const auto jayatilleke_P =
139 9.24 * (pow(Pr_ratio, 0.75) - 1.0) * (1.0 + 0.28 * exp(-0.007 * Pr_ratio));
140 const auto wall_scaling =
141 1.0 / NS::von_karman_constant * log(NS::E_turb_constant * y_plus) + jayatilleke_P;
142 T_plus = Pr_t * wall_scaling;
143 }
144 // Returns the effective thermal conductivity at the wall
145 return rho * cp * u_tau * wall_dist / T_plus;
146}
147
148Real
153
154Real
156{
157 const auto elem_arg = makeElemArg(_current_face_type == FaceInfo::VarFaceNeighbors::ELEM
160 const Real distance = computeCellToFaceDistance();
162 raw_value(_var(elem_arg, determineState()))) /
163 distance;
164}
165
166Real
168{
169 mooseError("We should not solve for the turbulent viscosity directly meaning that this should "
170 "contribute to neither vector nor a right hand side.");
171}
172
173Real
175{
176 mooseError("We should not solve for the turbulent viscosity directly meaning that this should "
177 "contribute to neither vector nor a right hand side.");
178}
179
180Real
182{
183 mooseError("We should not solve for the turbulent viscosity directly meaning that this should "
184 "contribute to neither vector nor a right hand side.");
185}
186
187Real
189{
190 mooseError("We should not solve for the turbulent viscosity directly meaning that this should "
191 "contribute to neither vector nor a right hand side.");
192}
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
const double rho
registerMooseObject("NavierStokesApp", LinearFVTemperatureWallFunctionBC)
const Point & normal() const
const Elem * neighborPtr() const
const Elem * elemPtr() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const FaceInfo * _current_face_info
Real computeCellToFaceDistance() const
FaceInfo::VarFaceNeighbors _current_face_type
MooseLinearVariableFV< Real > & _var
Class implementing a Dirichlet boundary condition for the turbulent viscosity wall function in a RANS...
const Moose::Functor< Real > & _mu
Dynamic viscosity.
LinearFVTemperatureWallFunctionBC(const InputParameters &parameters)
Class constructor.
virtual Real computeBoundaryGradientRHSContribution() const override
const Moose::Functor< Real > * _w_var
z-velocity
const Moose::Functor< Real > & _u_var
x-velocity
const Moose::Functor< Real > & _tke
Turbulent kinetic energy.
virtual Real computeBoundaryValueMatrixContribution() const override
Real computeTurbulentThermalConductivity() const
Compute the turbulent thermal conductivity.
const Real _C_mu
C_mu turbulent coefficient.
const NS::WallTreatmentEnum _wall_treatment
Method used for wall treatment.
virtual Real computeBoundaryValueRHSContribution() const override
const Moose::Functor< Real > & _k
Thermal Conductivity.
virtual Real computeBoundaryNormalGradient() const override
const Moose::Functor< Real > * _v_var
y-velocity
const Moose::Functor< Real > & _Pr_t
Turbulent Prandlt number.
virtual Real computeBoundaryGradientMatrixContribution() const override
const Moose::Functor< Real > & _cp
Specific Heat.
const Moose::Functor< Real > & _rho
Density.
void mooseError(Args &&... args) const
Moose::StateArg determineState() const
MeshBase & mesh
static const std::string density
Definition NS.h:34
template Real computeSpeed< Real >(const libMesh::VectorValue< Real > &velocity)
static constexpr Real von_karman_constant
Definition NS.h:206
static const std::string cp
Definition NS.h:125
static const std::string mu
Definition NS.h:127
static const std::string TKE
Definition NS.h:181
static const std::string k
Definition NS.h:134
static constexpr Real E_turb_constant
Definition NS.h:207
template Real findYplusThermal< Real >(const Real &Pr, const Real &Pr_t)
template Real findyPlus< Real >(const Real &mu, const Real &rho, const Real &u, Real dist)
template Real findUStar< Real >(const Real &mu, const Real &rho, const Real &u, const Real dist)
Real distance(const Point &p)