https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "NavierStokesMethods.h"
12
14
17{
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
59Real
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
101 RealVectorValue velocity(MetaPhysicL::raw_value(_u_var->getElemValue(&elem, state)));
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}
boundary_id_type BoundaryID
const double mu
const double rho
registerMooseObject("NavierStokesApp", WallFunctionYPlusAux)
SubProblem & _subproblem
const Elem *const & _current_elem
static InputParameters validParams()
const Point & normal() const
const Point & faceCentroid() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
bool isParamValid(const std::string &name) const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
const std::vector< const FaceInfo * > & faceInfo() const
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
ADReal getElemValue(const Elem *elem, const StateArg &state) const
virtual MooseMesh & mesh()=0
Moose::StateArg determineState() const
Computes wall y+ based on wall functions.
const INSFVVelocityVariable *const _w_var
z-velocity
virtual Real computeValue() override
const INSFVVelocityVariable *const _u_var
x-velocity
static InputParameters validParams()
const INSFVVelocityVariable *const _v_var
y-velocity
const std::vector< BoundaryName > & _wall_boundary_names
Wall boundaries.
WallFunctionYPlusAux(const InputParameters &parameters)
const unsigned int _dim
the dimension of the simulation
const Moose::Functor< Real > & _rho
Density.
const Moose::Functor< Real > & _mu
Dynamic viscosity.
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)
const boundary_id_type side_id