13 #include "libmesh/nonlinear_solver.h" 22 " terms of turbulent kinetic energy dissipation (TKED).");
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.");
30 params.
addParam<std::vector<BoundaryName>>(
31 "walls", {},
"Boundaries that correspond to solid walls.");
35 "Boolean to determine if the problem should be used in a linear or nonlinear solve");
36 MooseEnum wall_treatment(
"eq_newton eq_incremental eq_linearized neq",
"neq");
39 "The method used for computing the wall functions " 40 "'eq_newton', 'eq_incremental', 'eq_linearized', 'neq'");
41 params.
addParam<MooseFunctorName>(
"C1_eps", 1.44,
"First epsilon coefficient");
42 params.
addParam<MooseFunctorName>(
"C2_eps", 1.92,
"Second epsilon coefficient");
43 params.
addParam<
Real>(
"C_mu", 0.09,
"Coupled turbulent kinetic energy closure.");
44 params.
addParam<
Real>(
"C_pl", 10.0,
"Production limiter constant multiplier.");
45 params.
set<
unsigned short>(
"ghost_layers") = 2;
46 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 _C1_eps(getFunctor<
ADReal>(
"C1_eps")),
65 _C2_eps(getFunctor<
ADReal>(
"C2_eps")),
66 _C_mu(getParam<
Real>(
"C_mu")),
67 _C_pl(getParam<
Real>(
"C_pl")),
68 _newton_solve(getParam<bool>(
"newton_solve"))
71 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied!");
74 paramError(
"w",
"In three or more dimensions, the w velocity must be supplied!");
89 using std::max, std::sqrt,
std::pow, std::min;
96 const auto old_state =
98 const auto mu =
_mu(elem_arg, state);
99 const auto rho =
_rho(elem_arg, state);
106 std::vector<ADReal> y_plus_vec;
108 Real tot_weight = 0.0;
112 velocity(1) = (*_v_var)(elem_arg, state);
114 velocity(2) = (*_w_var)(elem_arg, state);
118 mooseAssert(distance_vec.size(),
"Should have found a distance vector");
119 mooseAssert(distance_vec.size() == face_info_vec.size(),
120 "Should be as many distance vectors as face info vectors");
122 for (
unsigned int i = 0; i < distance_vec.size(); i++)
124 const auto distance = distance_vec[i];
125 mooseAssert(
distance > 0,
"Should be at a non-zero distance");
133 velocity -
velocity * face_info_vec[i]->normal() * face_info_vec[i]->normal());
138 y_plus_vec.push_back(y_plus);
145 const auto y_plus = y_plus_vec[i];
149 const auto fi = face_info_vec[i];
151 const Elem *
const loc_elem = defined_on_elem_side ? &fi->elem() : fi->neighborPtr();
154 destruction += 2.0 * TKE_old *
_mu(facearg, state) /
rho /
155 Utility::pow<2>(distance_vec[i]) / tot_weight;
158 destruction +=
pow(
_C_mu, 0.75) *
pow(TKE_old, 1.5) /
168 const auto rz_radial_coord =
173 ADReal production_k =
_mu_t(elem_arg, state) * symmetric_strain_tensor_sq_norm;
179 production_k =
min(production_k, production_limit);
182 production =
_C1_eps(elem_arg, state) * production_k / time_scale;
183 destruction =
_C2_eps(elem_arg, state) *
rho *
_var(elem_arg, state) / time_scale;
185 residual = destruction - production;
unsigned int getAxisymmetricRadialCoord() const
const Moose::Functor< ADReal > * _w_var
z-velocity
const Moose::Functor< ADReal > & _C1_eps
Value of the first epsilon closure coefficient.
static constexpr Real von_karman_constant
static const std::string mu_t
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
void paramError(const std::string ¶m, Args... args) const
static InputParameters validParams()
Moose::StateArg determineState() const
const Moose::Functor< ADReal > & _k
Turbulent kinetic energy.
NS::WallTreatmentEnum _wall_treatment
Method used for wall treatment.
static const std::string density
static const std::string TKE
WallTreatmentEnum
Wall treatment options.
const Moose::Functor< ADReal > * _v_var
y-velocity
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
Computes the source and sink terms for the turbulent kinetic energy dissipation rate.
ADReal computeQpResidual() override
Real distance(const Point &p)
DualNumber< Real, DNDerivativeType, false > ADReal
auto max(const L &left, const R &right)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
const Moose::Functor< ADReal > & _rho
Density.
std::unordered_set< const Elem * > _wall_bounded
Maps for wall treatment.
registerMooseObject("NavierStokesApp", INSFVTKEDSourceSink)
const Elem *const & _current_elem
static const std::string mu
INSFVTKEDSourceSink(const InputParameters ¶meters)
static InputParameters validParams()
std::map< const Elem *, std::vector< Real > > _dist
FEProblemBase & _fe_problem
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...
const bool _newton_solve
Whether a nonlinear Newton-like solver is being used (as opposed to a linearized solver) ...
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
const unsigned int _dim
The dimension of the simulation.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
const Real _C_mu
C_mu constant.
template ADReal computeShearStrainRateNormSquared< ADReal >(const Moose::Functor< ADReal > &u, const Moose::Functor< ADReal > *v, const Moose::Functor< ADReal > *w, const Moose::ElemArg &elem_arg, const Moose::StateArg &state, const Moose::CoordinateSystemType coord_sys, const unsigned int rz_radial_coord)
template ADReal findyPlus< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
const bool _linearized_model
If the user wants to use the linearized model.
const Moose::Functor< ADReal > & _mu
Dynamic viscosity.
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-...
const Moose::Functor< ADReal > & _mu_t
Turbulent dynamic viscosity.
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
static const std::string velocity
const Moose::Functor< ADReal > & _C2_eps
Value of the second epsilon closure coefficient.
virtual void initialSetup() override
auto min(const L &left, const R &right)
MooseUnits pow(const MooseUnits &, int)
auto index_range(const T &sizable)
const Moose::Functor< ADReal > & _u_var
x-velocity
MooseVariableFV< Real > & _var
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override