https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
46{
47 mooseError("Sheer-stress-based wall function enforcement not supported for segregated solvers.");
48 return 0.0;
49}
50
53{
54 using std::abs;
55
56 // Get the velocity vector
57 const FaceInfo & fi = *_face_info;
58 const Elem & elem = fi.elem();
59 const Moose::ElemArg elem_arg{&elem, false};
60 const auto state = determineState();
61 ADRealVectorValue velocity(_u(elem_arg, state));
62 if (_v)
63 velocity(1) = (*_v)(elem_arg, state);
64 if (_w)
65 velocity(2) = (*_w)(elem_arg, state);
66
67 // Compute the velocity magnitude (parallel_speed) and
68 // direction of the tangential velocity component (parallel_dir)
69 ADReal dist = abs((fi.elemCentroid() - fi.faceCentroid()) * _normal);
70 ADReal perpendicular_speed = velocity * _normal;
71 ADRealVectorValue parallel_velocity = velocity - perpendicular_speed * _normal;
72 ADReal parallel_speed = parallel_velocity.norm();
73 _a = 1 / parallel_speed;
74
75 if (parallel_speed.value() < 1e-7)
76 return 0;
77
78 if (!std::isfinite(parallel_speed.value()))
79 return parallel_speed;
80
81 // Compute the friction velocity and the wall shear stress
82 const auto rho = _rho(makeElemArg(&elem), state);
83 ADReal u_star =
84 NS::findUStar<ADReal>(_mu(makeElemArg(&elem), state), rho, parallel_speed, dist.value());
85 ADReal tau = u_star * u_star * rho;
86 _a *= tau;
87
88 // Compute the shear stress component for this momentum equation
89 if (_index == 0)
90 return _a * parallel_velocity(0);
91 else if (_index == 1)
92 return _a * parallel_velocity(1);
93 else
94 return _a * parallel_velocity(2);
95}
96
97void
99{
100 _face_info = &fi;
101 _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
102 _normal = fi.normal();
103
104 // Fill-in the coefficient _a (but without multiplication by A)
105 const auto strong_resid = computeStrongResidual();
106
107 _rc_uo.addToA((_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? &fi.elem() : fi.neighborPtr(),
108 _index,
109 _a * (fi.faceArea() * fi.faceCoord()));
110
111 addResidualAndJacobian(strong_resid * (fi.faceArea() * fi.faceCoord()));
112}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesApp", INSFVWallFunctionBC)
MooseVariableFV< Real > & _var
const FaceInfo * _face_info
ADRealVectorValue _normal
FaceInfo::VarFaceNeighbors _face_type
const Point & normal() const
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Elem & elem() const
const Elem * neighborPtr() const
Real faceArea() const
Real & faceCoord()
const Point & elemCentroid() const
const Point & faceCentroid() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
void addResidualAndJacobian(const ADReal &residual)
Process into either the system residual or Jacobian.
Definition INSFVFluxBC.C:57
const unsigned int _index
index x|y|z
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms.
A class for free slip boundary conditions for the velocity.
static InputParameters validParams()
A class for setting the wall shear stress at the walls, based on the standard wall function formulati...
const Moose::Functor< ADReal > *const _v
y-velocity
const Moose::Functor< ADReal > & _u
x-velocity
ADReal _a
Rhie-Chow coefficient.
ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
const Moose::Functor< ADReal > & _mu
dynamic viscosity
const Moose::Functor< ADReal > & _rho
density
static InputParameters validParams()
const Moose::Functor< ADReal > *const _w
z-velocity
void gatherRCData(const FaceInfo &) override final
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
INSFVWallFunctionBC(const InputParameters &params)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
SystemBase & sys()
unsigned int number() const
virtual bool segregated() const =0
Bool of the Rhie Chow user object is used in monolithic/segregated approaches.
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.
unsigned int number() const
Moose::StateArg determineState() const
MeshBase & mesh
static const std::string density
Definition NS.h:34
template ADReal findUStar< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, const Real dist)