13 #include "libmesh/nonlinear_solver.h" 22 " terms of turbulent kinetic energy (TKE).");
23 params.
addRequiredParam<MooseFunctorName>(
"u",
"The velocity in the x direction.");
24 params.
addParam<MooseFunctorName>(
"v",
"The velocity in the y direction.");
25 params.
addParam<MooseFunctorName>(
"w",
"The velocity in the z direction.");
27 "Coupled turbulent kinetic energy dissipation rate.");
31 params.
addParam<std::vector<BoundaryName>>(
32 "walls", {},
"Boundaries that correspond to solid walls.");
36 "Boolean to determine if the problem should be use in a linear or nonlinear solve.");
37 MooseEnum wall_treatment(
"eq_newton eq_incremental eq_linearized neq",
"neq");
40 "The method used for computing the wall functions " 41 "'eq_newton', 'eq_incremental', 'eq_linearized', 'neq'");
42 params.
addParam<
Real>(
"C_mu", 0.09,
"Coupled turbulent kinetic energy closure.");
43 params.
addParam<
Real>(
"C_pl", 10.0,
"Production Limiter Constant Multiplier.");
44 params.
set<
unsigned short>(
"ghost_layers") = 2;
45 params.
addParam<
bool>(
"newton_solve",
false,
"Whether a Newton nonlinear solve is being used");
53 _dim(_subproblem.
mesh().dimension()),
54 _u_var(getFunctor<
ADReal>(
"u")),
55 _v_var(params.isParamValid(
"v") ? &(getFunctor<
ADReal>(
"v")) : nullptr),
56 _w_var(params.isParamValid(
"w") ? &(getFunctor<
ADReal>(
"w")) : nullptr),
61 _wall_boundary_names(getParam<
std::vector<BoundaryName>>(
"walls")),
62 _linearized_model(getParam<bool>(
"linearized_model")),
64 _C_mu(getParam<
Real>(
"C_mu")),
65 _C_pl(getParam<
Real>(
"C_pl")),
66 _newton_solve(getParam<bool>(
"newton_solve"))
69 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied!");
72 paramError(
"w",
"In three or more dimensions, the w velocity must be supplied!");
93 const auto old_state =
95 const auto rho =
_rho(elem_arg, state);
96 const auto mu =
_mu(elem_arg, state);
99 ? std::max(
_var(elem_arg, old_state),
ADReal(0) *
_var(elem_arg, old_state))
100 :
_var(elem_arg, old_state);
104 TKE = std::max(
TKE, 1e-10);
108 std::vector<ADReal> y_plus_vec, velocity_grad_norm_vec;
110 Real tot_weight = 0.0;
114 velocity(1) = (*_v_var)(elem_arg, state);
116 velocity(2) = (*_w_var)(elem_arg, state);
121 for (
unsigned int i = 0; i < distance_vec.size(); i++)
124 velocity -
velocity * face_info_vec[i]->normal() * face_info_vec[i]->normal());
125 const auto distance = distance_vec[i];
133 y_plus_vec.push_back(y_plus);
153 velocity_grad_norm_vec.push_back(velocity_grad_norm);
158 for (
unsigned int i = 0; i < y_plus_vec.size(); i++)
160 const auto y_plus = y_plus_vec[i];
162 const auto fi = face_info_vec[i];
164 const Elem *
const loc_elem = defined_on_elem_side ? &fi->elem() : fi->neighborPtr();
168 const ADReal wall_mu =
_mu(facearg, state);
170 const auto destruction_visc = 2.0 * wall_mu / Utility::pow<2>(distance_vec[i]) / tot_weight;
173 const auto tau_w = (wall_mut + wall_mu) * velocity_grad_norm_vec[i];
178 destruction += destruction_visc;
180 destruction += 0 * destruction_log + 0 * tau_w;
184 destruction += destruction_log;
186 destruction += 0 * destruction_visc;
192 residual = (destruction - production) *
_var(elem_arg, state);
195 residual += 0 *
_epsilon(elem_arg, old_state);
199 const auto & grad_u =
_u_var.gradient(elem_arg, state);
200 const auto Sij_xx = 2.0 * grad_u(0);
207 const auto grad_xx = grad_u(0);
217 auto trace = Sij_xx / 3.0;
221 const auto & grad_v = (*_v_var).gradient(elem_arg, state);
222 Sij_xy = grad_u(1) + grad_v(0);
223 Sij_yy = 2.0 * grad_v(1);
229 trace += Sij_yy / 3.0;
233 const auto & grad_w = (*_w_var).gradient(elem_arg, state);
235 Sij_xz = grad_u(2) + grad_w(0);
236 Sij_yz = grad_v(2) + grad_w(1);
237 Sij_zz = 2.0 * grad_w(2);
245 trace += Sij_zz / 3.0;
249 const auto symmetric_strain_tensor_sq_norm =
250 (Sij_xx - trace) * grad_xx + Sij_xy * grad_xy + Sij_xz * grad_xz + Sij_xy * grad_yx +
251 (Sij_yy - trace) * grad_yy + Sij_yz * grad_yz + Sij_xz * grad_zx + Sij_yz * grad_zy +
252 (Sij_zz - trace) * grad_zz;
254 production =
_mu_t(elem_arg, state) * symmetric_strain_tensor_sq_norm;
257 const auto epsilon_old =
_epsilon(elem_arg, old_state);
260 destruction = rho * epsilon_old;
262 destruction = rho *
_var(elem_arg, state) / tke_old_raw *
raw_value(epsilon_old);
265 const ADReal production_limit =
269 production = std::min(production, production_limit);
271 residual = destruction - production;
275 residual += 0 *
_epsilon(elem_arg, state);
const bool _newton_solve
For Newton solves we want to add extra zero-valued terms regardless of y-plus to avoid sparsity patte...
static constexpr Real von_karman_constant
const bool _linearized_model
Linearized model?
static const std::string mu_t
const Moose::Functor< ADReal > & _mu_t
Turbulent dynamic viscosity.
const Moose::Functor< ADReal > * _w_var
z-velocity
const Real _C_mu
C_mu constant.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
ADReal computeQpResidual() override
std::map< const Elem *, bool > _wall_bounded
void getWallBoundedElements(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::map< const Elem *, bool > &wall_bounded_map)
Map marking wall bounded elements The map passed in wall_bounded_map gets cleared and re-populated...
Moose::StateArg determineState() const
static const std::string density
static const std::string TKE
WallTreatmentEnum
Wall treatment options.
const Moose::Functor< ADReal > & _u_var
x-velocity
virtual const std::set< SubdomainID > & blockIDs() const
const Moose::Functor< ADReal > & _mu
Dynamic viscosity.
const Moose::Functor< ADReal > & _rho
Density.
DualNumber< Real, DNDerivativeType, true > ADReal
std::map< const Elem *, std::vector< Real > > _dist
Real distance(const Point &p)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
const Elem *const & _current_elem
static const std::string mu
NS::WallTreatmentEnum _wall_treatment
Method used for wall treatment.
static InputParameters validParams()
ADReal findyPlus(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
Finds the non-dimensional wall distance normalized with the friction velocity Implements a fixed-poin...
FEProblemBase & _fe_problem
const Moose::Functor< ADReal > * _v_var
y-velocity
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
void getWallDistance(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::map< const Elem *, std::vector< Real >> &dist_map)
Map storing wall ditance for near-wall marked elements The map passed in dist_map gets cleared and re...
const unsigned int _dim
The dimension of the domain.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string TKED
registerMooseObject("NavierStokesApp", INSFVTKESourceSink)
void getElementFaceArgs(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::map< const Elem *, std::vector< const FaceInfo *>> &face_info_map)
Map storing face arguments to wall bounded faces The map passed in face_info_map gets cleared and re-...
static const std::string velocity
Computes source the sink terms for the turbulent kinetic energy.
virtual void initialSetup() override
ADReal computeSpeed(const ADRealVectorValue &velocity)
Compute the speed (velocity norm) given the supplied velocity.
const Moose::Functor< ADReal > & _epsilon
epsilon - dissipation rate of TKE
std::map< const Elem *, std::vector< const FaceInfo * > > _face_infos
MooseUnits pow(const MooseUnits &, int)
MooseVariableFV< Real > & _var
INSFVTKESourceSink(const InputParameters ¶meters)
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override