https://mooseframework.inl.gov
WallFunctionYPlusAux.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 
10 #include "WallFunctionYPlusAux.h"
11 #include "NavierStokesMethods.h"
12 
13 registerMooseObject("NavierStokesApp", WallFunctionYPlusAux);
14 
17 {
19  params.addClassDescription(
20  "Calculates y+ value according to the algebraic velocity standard wall function.");
21  params.addRequiredCoupledVar("u", "The velocity in the x direction.");
22  params.addCoupledVar("v", "The velocity in the y direction.");
23  params.addCoupledVar("w", "The velocity in the z direction.");
24  params.addRequiredParam<MooseFunctorName>("rho", "fluid density");
25  params.addRequiredParam<MooseFunctorName>("mu", "Dynamic viscosity");
26  params.addRequiredParam<std::vector<BoundaryName>>("walls",
27  "Boundaries that correspond to solid walls");
28  return params;
29 }
30 
32  : AuxKernel(params),
33  _dim(_subproblem.mesh().dimension()),
34  _u_var(dynamic_cast<const INSFVVelocityVariable *>(getFieldVar("u", 0))),
35  _v_var(params.isParamValid("v")
36  ? dynamic_cast<const INSFVVelocityVariable *>(getFieldVar("v", 0))
37  : nullptr),
38  _w_var(params.isParamValid("w")
39  ? dynamic_cast<const INSFVVelocityVariable *>(getFieldVar("w", 0))
40  : nullptr),
41  _rho(getFunctor<Real>("rho")),
42  _mu(getFunctor<Real>("mu")),
43  _wall_boundary_names(getParam<std::vector<BoundaryName>>("walls"))
44 {
45  if (!_u_var)
46  paramError("u", "the u velocity must be an INSFVVelocityVariable.");
47 
48  if (_dim >= 2 && !_v_var)
49  paramError("v",
50  "In two or more dimensions, the v velocity must be supplied and it must be an "
51  "INSFVVelocityVariable.");
52 
53  if (_dim >= 3 && !params.isParamValid("w"))
54  paramError("w",
55  "In three-dimensions, the w velocity must be supplied and it must be an "
56  "INSFVVelocityVariable.");
57 }
58 
59 Real
61 {
62  const Elem & elem = *_current_elem;
63 
64  bool wall_bounded = false;
65  Real min_wall_dist = 1e10;
66  Point wall_vec;
67  Point normal;
68  for (unsigned int i_side = 0; i_side < elem.n_sides(); ++i_side)
69  {
70  const std::vector<BoundaryID> side_bnds =
72  for (const BoundaryName & name : _wall_boundary_names)
73  {
75  for (BoundaryID side_id : side_bnds)
76  {
77  if (side_id == wall_id)
78  {
79  const FaceInfo * const fi = _mesh.faceInfo(&elem, i_side);
80  const Point & this_normal = fi->normal();
81  Point this_wall_vec = (elem.vertex_average() - fi->faceCentroid());
82  Real dist = std::abs(this_wall_vec * normal);
83  if (dist < min_wall_dist)
84  {
85  min_wall_dist = dist;
86  wall_vec = this_wall_vec;
87  normal = this_normal;
88  }
89  wall_bounded = true;
90  }
91  }
92  }
93  }
94 
95  if (!wall_bounded)
96  return 0;
97 
98  const auto state = determineState();
99 
100  // Get the velocity vector
102  if (_v_var)
103  velocity(1) = MetaPhysicL::raw_value(_v_var->getElemValue(&elem, state));
104  if (_w_var)
105  velocity(2) = MetaPhysicL::raw_value(_w_var->getElemValue(&elem, state));
106 
107  // Compute the velocity and direction of the velocity component that is parallel to the wall
108  Real dist = std::abs(wall_vec * normal);
109  const Real perpendicular_speed = velocity * normal;
110  const RealVectorValue parallel_velocity = velocity - perpendicular_speed * normal;
111  const Real parallel_speed = parallel_velocity.norm();
112 
113  if (parallel_speed < 1e-6)
114  return 0;
115 
116  if (!std::isfinite(parallel_speed))
117  return parallel_speed;
118 
119  // Compute the friction velocity and the wall shear stress
120  const auto elem_arg = makeElemArg(_current_elem);
121  const auto rho = _rho(elem_arg, state);
122  const auto mu = _mu(elem_arg, state);
123  const Real u_star = NS::findUStar<Real>(mu, rho, parallel_speed, dist);
124 
125  return (dist * u_star * rho / mu);
126 }
virtual MooseMesh & mesh()=0
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
auto norm() const -> decltype(std::norm(Real()))
Moose::StateArg determineState() const
const boundary_id_type side_id
const Point & faceCentroid() const
virtual Real computeValue() override
MeshBase & mesh
auto raw_value(const Eigen::Map< T > &in)
template Real findUStar< Real >(const Real &mu, const Real &rho, const Real &u, const Real dist)
virtual const std::string & name() const
ADReal getElemValue(const Elem *elem, const StateArg &state) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
const INSFVVelocityVariable *const _v_var
y-velocity
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
const std::vector< const FaceInfo *> & faceInfo() const
WallFunctionYPlusAux(const InputParameters &parameters)
static const std::string mu
Definition: NS.h:123
boundary_id_type BoundaryID
static InputParameters validParams()
const INSFVVelocityVariable *const _u_var
x-velocity
const Point & normal() const
void paramError(const std::string &param, Args... args) const
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
registerMooseObject("NavierStokesApp", WallFunctionYPlusAux)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SubProblem & _subproblem
const Elem *const & _current_elem
const INSFVVelocityVariable *const _w_var
z-velocity
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static const std::string velocity
Definition: NS.h:45
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Computes wall y+ based on wall functions.
const Moose::Functor< Real > & _mu
Dynamic viscosity.
const unsigned int _dim
the dimension of the simulation
const Moose::Functor< Real > & _rho
Density.
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
bool isParamValid(const std::string &name) const