https://mooseframework.inl.gov
INSFVWallFunctionBC.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 "INSFVWallFunctionBC.h"
11 #include "NavierStokesMethods.h"
12 #include "NS.h"
13 
14 registerMooseObject("NavierStokesApp", INSFVWallFunctionBC);
15 
18 {
20  params.addClassDescription("Implements a wall shear BC for the momentum equation based on "
21  "algebraic standard velocity wall functions.");
22  params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
23  params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
24  params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
25  params.addRequiredParam<MooseFunctorName>(NS::density, "fluid density");
26  params.addRequiredParam<MooseFunctorName>("mu", "Dynamic viscosity");
27  return params;
28 }
29 
31  : INSFVNaturalFreeSlipBC(params),
32  _dim(_subproblem.mesh().dimension()),
33  _u(getFunctor<ADReal>("u")),
34  _v(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr),
35  _w(isParamValid("w") ? &getFunctor<ADReal>("w") : nullptr),
36  _rho(getFunctor<ADReal>(NS::density)),
37  _mu(getFunctor<ADReal>("mu"))
38 {
39  if (_rc_uo.segregated())
40  mooseError("Wall sheer stress enforcement based wall functions are not supported with "
41  "segregated solution approaches!");
42 }
43 
44 ADReal
46 {
47  mooseError("Sheer-stress-based wall function enforcement not supported for segregated solvers.");
48  return 0.0;
49 }
50 
51 ADReal
53 {
54  // Get the velocity vector
55  const FaceInfo & fi = *_face_info;
56  const Elem & elem = fi.elem();
57  const Moose::ElemArg elem_arg{&elem, false};
58  const auto state = determineState();
59  ADRealVectorValue velocity(_u(elem_arg, state));
60  if (_v)
61  velocity(1) = (*_v)(elem_arg, state);
62  if (_w)
63  velocity(2) = (*_w)(elem_arg, state);
64 
65  // Compute the velocity magnitude (parallel_speed) and
66  // direction of the tangential velocity component (parallel_dir)
67  ADReal dist = std::abs((fi.elemCentroid() - fi.faceCentroid()) * _normal);
68  ADReal perpendicular_speed = velocity * _normal;
69  ADRealVectorValue parallel_velocity = velocity - perpendicular_speed * _normal;
70  ADReal parallel_speed = parallel_velocity.norm();
71  _a = 1 / parallel_speed;
72 
73  if (parallel_speed.value() < 1e-7)
74  return 0;
75 
76  if (!std::isfinite(parallel_speed.value()))
77  return parallel_speed;
78 
79  // Compute the friction velocity and the wall shear stress
80  const auto rho = _rho(makeElemArg(&elem), state);
81  ADReal u_star = NS::findUStar(_mu(makeElemArg(&elem), state), rho, parallel_speed, dist.value());
82  ADReal tau = u_star * u_star * rho;
83  _a *= tau;
84 
85  // Compute the shear stress component for this momentum equation
86  if (_index == 0)
87  return _a * parallel_velocity(0);
88  else if (_index == 1)
89  return _a * parallel_velocity(1);
90  else
91  return _a * parallel_velocity(2);
92 }
93 
94 void
96 {
97  _face_info = &fi;
98  _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
99  _normal = fi.normal();
100 
101  // Fill-in the coefficient _a (but without multiplication by A)
102  const auto strong_resid = computeStrongResidual();
103 
105  _index,
106  _a * (fi.faceArea() * fi.faceCoord()));
107 
108  addResidualAndJacobian(strong_resid * (fi.faceArea() * fi.faceCoord()));
109 }
const Moose::Functor< ADReal > *const _v
y-velocity
const FaceInfo * _face_info
FaceInfo::VarFaceNeighbors _face_type
auto norm() const -> decltype(std::norm(T()))
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int number() const
ADReal _a
Rhie-Chow coefficient.
const Elem & elem() const
Moose::StateArg determineState() const
const Point & faceCentroid() const
const unsigned int _index
index x|y|z
MeshBase & mesh
static const std::string density
Definition: NS.h:33
static InputParameters validParams()
MooseVariableFV< Real > & _var
Real & faceCoord()
DualNumber< Real, DNDerivativeType, true > ADReal
Real faceArea() const
const Moose::Functor< ADReal > & _mu
dynamic viscosity
void addRequiredParam(const std::string &name, const std::string &doc_string)
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms...
INSFVWallFunctionBC(const InputParameters &params)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
const Moose::Functor< ADReal > *const _w
z-velocity
const Elem * neighborPtr() const
const Point & elemCentroid() const
virtual bool segregated() const =0
Bool of the Rhie Chow user object is used in monolithic/segregated approaches.
ADRealVectorValue _normal
const Point & normal() const
unsigned int number() const
void addResidualAndJacobian(const ADReal &residual)
Process into either the system residual or Jacobian.
Definition: INSFVFluxBC.C:57
static InputParameters validParams()
A class for setting the wall shear stress at the walls, based on the standard wall function formulati...
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value)=0
API for momentum residual objects that have on-diagonals for velocity call.
void gatherRCData(const FaceInfo &) override final
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static const std::string velocity
Definition: NS.h:45
const Moose::Functor< ADReal > & _rho
density
ADReal findUStar(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
Finds the friction velocity using standard velocity wall functions formulation.
ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
registerMooseObject("NavierStokesApp", INSFVWallFunctionBC)
A class for free slip boundary conditions for the velocity.
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Moose::Functor< ADReal > & _u
x-velocity