12 #include "libmesh/vector_value.h" 18 delta(
unsigned int i,
unsigned int j)
29 return a > 0 ? 1 : (
a < 0 ? -1 : 0);
33 getIndex(
const Real & p,
const std::vector<Real> & bounds)
35 if (p < bounds.front() || p > bounds.back())
38 for (
unsigned int i = 1; i < bounds.size(); ++i)
42 return bounds.size() - 2;
47 const Real & Re,
const Real & rho,
const Real &
mu,
const Real & drho,
const Real & dmu)
49 return Re * (drho / std::max(rho, 1e-6) - dmu / std::max(
mu, 1e-8));
60 return (
k * (
mu * dcp +
cp * dmu) -
mu *
cp * dk) / std::max(
k *
k, 1e-8);
67 constexpr
int MAX_ITERS{50};
68 constexpr
Real REL_TOLERANCE{1e-6};
71 mooseAssert(
mu > 0,
"Need a strictly positive viscosity");
72 mooseAssert(rho > 0,
"Need a strictly positive density");
73 mooseAssert(u > 0,
"Need a strictly positive velocity");
74 mooseAssert(dist > 0,
"Need a strictly positive wall distance");
86 std::max(1e-20, (-b_c + std::sqrt(
std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c));
89 for (
int i = 0; i < MAX_ITERS; ++i)
95 ADReal new_u_star = std::max(1e-20, u_star - residual /
deriv);
97 Real rel_err = std::abs((new_u_star.value() - u_star.value()) / new_u_star.value());
100 if (rel_err < REL_TOLERANCE)
104 mooseException(
"Could not find the wall friction velocity (mu: ",
120 constexpr
int MAX_ITERS{10};
121 constexpr
Real REL_TOLERANCE{1e-2};
124 mooseAssert(
mu > 0,
"Need a strictly positive viscosity");
125 mooseAssert(u > 0,
"Need a strictly positive velocity");
126 mooseAssert(rho > 0,
"Need a strictly positive density");
127 mooseAssert(dist > 0,
"Need a strictly positive wall distance");
129 Real yPlusLast = 0.0;
131 const Real rev_yPlusLam = 1.0 / yPlus.value();
133 unsigned int iters = 0;
137 yPlusLast = yPlus.value();
141 }
while (std::abs(rev_yPlusLam * (yPlus.value() - yPlusLast)) > REL_TOLERANCE &&
142 ++iters < MAX_ITERS);
162 const std::set<SubdomainID> & block_ids,
163 std::map<const Elem *, bool> & wall_bounded_map)
166 wall_bounded_map.clear();
169 for (
const auto & elem : fe_problem.
mesh().
getMesh().active_element_ptr_range())
171 if (block_ids.find(elem->subdomain_id()) != block_ids.end())
172 for (
const auto i_side : elem->side_index_range())
175 for (
const auto & wall_id : wall_boundary_ids)
177 for (
const auto side_id : side_bnds)
179 wall_bounded_map[elem] =
true;
190 const std::set<SubdomainID> & block_ids,
191 std::map<
const Elem *, std::vector<Real>> & dist_map)
196 for (
const auto & elem : fe_problem.
mesh().
getMesh().active_element_ptr_range())
197 if (block_ids.find(elem->subdomain_id()) != block_ids.end())
198 for (
const auto i_side : elem->side_index_range())
201 for (
const auto &
name : wall_boundary_name)
204 for (
const auto side_id : side_bnds)
209 dist_map[elem].push_back(dist);
220 const std::set<SubdomainID> & block_ids,
221 std::map<
const Elem *, std::vector<const FaceInfo *>> & face_info_map)
224 face_info_map.clear();
226 for (
const auto & elem : fe_problem.
mesh().
getMesh().active_element_ptr_range())
227 if (block_ids.find(elem->subdomain_id()) != block_ids.end())
228 for (
const auto i_side : elem->side_index_range())
231 for (
const auto &
name : wall_boundary_name)
234 for (
const auto side_id : side_bnds)
238 face_info_map[elem].push_back(fi);
virtual MooseMesh & mesh()=0
int computeSign(const Real &a)
Sign function, returns $+1$ if $a$ is positive and $-1$ if $a$ is negative.
static constexpr Real von_karman_constant
static constexpr Real min_y_plus
void mooseError(Args &&... args)
Real prandtlPropertyDerivative(const Real &mu, const Real &cp, const Real &k, const Real &dmu, const Real &dcp, const Real &dk)
Computes the derivative of the Prandtl number, $Pr{ C_p}{k}$, with respect to an arbitrary variale $$...
bool isZero(const T &value, const Real tolerance=TOLERANCE *TOLERANCE *TOLERANCE)
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...
const boundary_id_type side_id
const Point & faceCentroid() const
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i j$ and unity if $i=j$.
DualNumber< Real, DNDerivativeType, true > ADReal
static const std::string cp
const std::vector< const FaceInfo *> & faceInfo() const
const Point & elemCentroid() const
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
static const std::string mu
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...
Real reynoldsPropertyDerivative(const Real &Re, const Real &rho, const Real &mu, const Real &drho, const Real &dmu)
Computes the derivative of the Reynolds number, $Re { Vd}{}$, with respect to an arbitrary variable $...
const Point & normal() const
unsigned int getIndex(const Real &p, const std::vector< Real > &bounds)
Determines the index $i$ in a sorted array such that the input point is within the $i$-th and $i+1$-t...
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...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static constexpr Real E_turb_constant
virtual MooseMesh & mesh() override
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
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
ADReal findUStar(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
Finds the friction velocity using standard velocity wall functions formulation.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
ADReal computeSpeed(const ADRealVectorValue &velocity)
Compute the speed (velocity norm) given the supplied velocity.
MooseUnits pow(const MooseUnits &, int)
static const std::string k
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const