13 #include "libmesh/nonlinear_solver.h" 22 "Calculates the turbulent viscosity according to the k-epsilon model.");
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.");
26 params.
addRequiredParam<MooseFunctorName>(
"k",
"Coupled turbulent kinetic energy.");
29 "Coupled turbulent kinetic energy dissipation rate.");
32 params.
addParam<
Real>(
"C_mu",
"Coupled turbulent kinetic energy closure.");
33 params.
addParam<
Real>(
"mu_t_ratio_max", 1e5,
"Maximum allowable mu_t_ratio : mu/mu_t.");
34 params.
addParam<std::vector<BoundaryName>>(
35 "walls", {},
"Boundaries that correspond to solid walls.");
36 params.
addParam<
bool>(
"bulk_wall_treatment",
false,
"Activate bulk wall treatment.");
37 MooseEnum wall_treatment(
"eq_newton eq_incremental eq_linearized neq",
"eq_newton");
40 "The method used for computing the wall functions." 41 "'eq_newton', 'eq_incremental', 'eq_linearized', 'neq'");
42 MooseEnum scale_limiter(
"none standard",
"standard");
45 "The method used to limit the k-epsilon time scale." 46 "'none', 'standard'");
47 params.
addParam<
bool>(
"newton_solve",
false,
"Whether a Newton nonlinear solve is being used");
55 _dim(_subproblem.
mesh().dimension()),
56 _u_var(getFunctor<
Real>(
"u")),
57 _v_var(params.isParamValid(
"v") ? &(getFunctor<
Real>(
"v")) : nullptr),
58 _w_var(params.isParamValid(
"w") ? &(getFunctor<
Real>(
"w")) : nullptr),
63 _C_mu(getParam<
Real>(
"C_mu")),
64 _mu_t_ratio_max(getParam<
Real>(
"mu_t_ratio_max")),
65 _wall_boundary_names(getParam<
std::vector<BoundaryName>>(
"walls")),
66 _bulk_wall_treatment(getParam<bool>(
"bulk_wall_treatment")),
68 _scale_limiter(getParam<
MooseEnum>(
"scale_limiter")),
69 _newton_solve(getParam<bool>(
"newton_solve"))
95 const auto nu =
mu / rho;
107 const auto & elem_distances =
_dist[&elem];
108 const auto min_wall_distance_iterator =
109 (std::min_element(elem_distances.begin(), elem_distances.end()));
110 const auto min_wall_dist = *min_wall_distance_iterator;
111 const size_t minIndex = std::distance(elem_distances.begin(), min_wall_distance_iterator);
112 const auto loc_normal =
_face_infos[&elem][minIndex]->normal();
117 velocity(1) = (*_v_var)(elem_arg, state);
119 velocity(2) = (*_w_var)(elem_arg, state);
122 const auto parallel_speed =
135 y_plus = min_wall_dist * u_tau * rho /
mu;
136 mu_wall = rho * Utility::pow<2>(u_tau) * min_wall_dist / parallel_speed;
137 mut_log = mu_wall -
mu;
145 mut_log = mu_wall -
mu;
153 const Real c_c = parallel_speed;
155 const auto u_tau = (-b_c + std::sqrt(
std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c);
156 y_plus = min_wall_dist * u_tau * rho /
mu;
157 mu_wall = rho * Utility::pow<2>(u_tau) * min_wall_dist / parallel_speed;
158 mut_log = mu_wall -
mu;
163 y_plus = min_wall_dist * std::sqrt(std::sqrt(
_C_mu) *
_k(elem_arg, state)) * rho /
mu;
166 mut_log = mu_wall -
mu;
169 mooseAssert(
false,
"For `kEpsilonViscosityAux` , wall treatment should not reach here");
174 else if (y_plus >= 30.0)
180 const auto blending_function = (y_plus - 5.0) / 25.0;
193 time_scale = std::max(
_k(elem_arg, state) /
_epsilon(elem_arg, state),
194 std::sqrt(nu /
_epsilon(elem_arg, state)));
198 time_scale =
_k(elem_arg, state) /
_epsilon(elem_arg, state);
204 const Real mu_t_nl =
_rho(elem_arg, state) *
_C_mu *
_k(elem_arg, state) * time_scale;
std::unordered_set< const Elem * > _wall_bounded
virtual void initialSetup() override
static constexpr Real von_karman_constant
static const std::string mu_t
const Moose::Functor< Real > & _mu
Dynamic viscosity.
const Moose::Functor< Real > & _rho
Density.
Computes the turbuent viscosity for the k-Epsilon model.
const Real _mu_t_ratio_max
const bool _bulk_wall_treatment
If the user wants to enable bulk wall treatment.
Moose::StateArg determineState() const
static const std::string density
static const std::string TKE
WallTreatmentEnum
Wall treatment options.
template Real findUStar< Real >(const Real &mu, const Real &rho, const Real &u, const Real dist)
void getWallBoundedElements(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::unordered_set< const Elem *> &wall_bounded)
Map marking wall bounded elements The map passed in wall_bounded_map gets cleared and re-populated...
virtual const std::set< SubdomainID > & blockIDs() const
const Moose::Functor< Real > & _epsilon
Turbulent kinetic energy dissipation rate.
const Moose::Functor< Real > & _u_var
x-velocity
const Moose::Functor< Real > & _k
Turbulent kinetic energy.
FEProblemBase & _c_fe_problem
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
template Real findyPlus< Real >(const Real &mu, const Real &rho, const Real &u, Real dist)
NS::WallTreatmentEnum _wall_treatment
Method used for wall treatment.
static const std::string mu
const bool _newton_solve
Whether we are using a newton solve.
std::map< const Elem *, std::vector< const FaceInfo * > > _face_infos
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...
std::map< const Elem *, std::vector< Real > > _dist
virtual Real computeValue() override
kEpsilonViscosityAux(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MooseEnum _scale_limiter
Method used to limit the k-e time scale.
static constexpr Real E_turb_constant
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
static const std::string TKED
const Elem *const & _current_elem
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 InputParameters validParams()
static const std::string velocity
registerMooseObject("NavierStokesApp", kEpsilonViscosityAux)
template Real computeSpeed< Real >(const libMesh::VectorValue< Real > &velocity)
static constexpr Real mu_t_low_limit
static InputParameters validParams()
const Moose::Functor< Real > * _w_var
z-velocity
MooseUnits pow(const MooseUnits &, int)
static constexpr Real epsilon_low_limit
const Real _C_mu
C-mu closure coefficient.
const Moose::Functor< Real > * _v_var
y-velocity