https://mooseframework.inl.gov
INSFVMomentumAdvectionOutflowBC.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 "INSFVVelocityVariable.h"
12 #include "SubProblem.h"
13 #include "MooseMesh.h"
14 #include "NS.h"
15 #include "SystemBase.h"
16 
18 
21 {
24  params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
25  params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
26  params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
27  params.addClassDescription("Fully developed outflow boundary condition for advecting momentum. "
28  "This will impose a zero normal gradient on the boundary velocity.");
29  params.addRequiredParam<MooseFunctorName>(NS::density, "The density");
30  return params;
31 }
32 
34  : INSFVFluxBC(params),
36  _u(getFunctor<ADReal>("u")),
37  _v(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr),
38  _w(isParamValid("w") ? &getFunctor<ADReal>("w") : nullptr),
39  _dim(_subproblem.mesh().dimension()),
40  _rho(getFunctor<ADReal>(NS::density))
41 {
42  if (_dim >= 2 && !_v)
43  mooseError(
44  "In two or more dimensions, the v velocity must be supplied using the 'v' parameter");
45  if (_dim >= 3 && !_w)
46  mooseError("In three dimensions, the w velocity must be supplied using the 'w' parameter");
47 }
48 
49 ADReal
51  const Moose::StateArg & state)
52 {
53  const auto rho_boundary = _rho(boundary_face, state);
54  const auto eps_boundary = epsFunctor()(boundary_face, state);
55 
56  // This will tend to be an extrapolated boundary for the velocity in which case, when using two
57  // term expansion, this boundary value will actually be a function of more than just the degree of
58  // freedom at the cell centroid adjacent to the face, e.g. it can/will depend on surrounding cell
59  // degrees of freedom as well
60  const auto var_boundary = _var(boundary_face, state);
61 
62  return rho_boundary / eps_boundary * var_boundary;
63 }
64 
65 ADReal
67 {
68  const auto boundary_face = singleSidedFaceArg();
69  const auto state = determineState();
70  return _normal *
72  *_face_info,
74  _tid,
75  /*subtract_mesh_velocity=*/true) *
76  computeAdvectedQuantity(boundary_face, state);
77 }
78 
79 void
81 {
82  using namespace Moose::FV;
83 
84  _face_info = &fi;
85  _normal = fi.normal();
86  _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
87 
89  _normal = -_normal;
90 
91  const auto boundary_face = singleSidedFaceArg();
92  const auto state = determineState();
93  ADRealVectorValue v(_u(boundary_face, state));
94  if (_v)
95  v(1) = (*_v)(boundary_face, state);
96  if (_w)
97  v(2) = (*_w)(boundary_face, state);
98 
99  const auto & elem = (_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? _face_info->elem()
100  : _face_info->neighbor();
101 
102  // This will tend to be an extrapolated boundary for the velocity in which case, when using two
103  // term expansion, this boundary value will actually be a function of more than just the degree of
104  // freedom at the cell centroid adjacent to the face, e.g. it can/will depend on surrounding cell
105  // degrees of freedom as well
106  const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
107  const auto advected_quant = computeAdvectedQuantity(boundary_face, state);
108  const auto a = advected_quant.derivatives()[dof_number] * _normal * v;
109 
110  const auto strong_resid = _normal * v * advected_quant;
111 
113  _index,
114  a * (fi.faceArea() * fi.faceCoord()));
115 
116  addResidualAndJacobian(strong_resid * (fi.faceArea() * fi.faceCoord()));
117 }
const FaceInfo * _face_info
ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
FaceInfo::VarFaceNeighbors _face_type
const Moose::Functor< ADReal > & _u
x-velocity
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
SystemBase & _sys
unsigned int number() const
A flux boundary condition that momentum residual objects that add boundary flux terms should inherit ...
Definition: INSFVFluxBC.h:19
const Moose::Functor< ADReal > & _rho
The density.
const Elem & elem() const
Moose::StateArg determineState() const
const unsigned int _index
index x|y|z
MeshBase & mesh
static const std::string density
Definition: NS.h:33
void gatherRCData(const FaceInfo &) override
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
MooseVariableFV< Real > & _var
Real & faceCoord()
DualNumber< Real, DNDerivativeType, true > ADReal
const Moose::Functor< ADReal > *const _v
y-velocity
Real faceArea() const
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual const Moose::FunctorBase< ADReal > & epsFunctor() const
A virtual method that can be overridden in PINSFV classes to return a non-unity porosity.
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms...
registerMooseObject("NavierStokesApp", INSFVMomentumAdvectionOutflowBC)
virtual VectorValue< ADReal > getVelocity(const Moose::FV::InterpMethod m, const FaceInfo &fi, const Moose::StateArg &time, const THREAD_ID tid, bool subtract_mesh_velocity) const =0
Retrieve a face velocity.
const Elem * neighborPtr() const
const Moose::Functor< ADReal > *const _w
z-velocity
const unsigned int _dim
the dimension of the simulation
const Elem & neighbor() const
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
THREAD_ID _tid
static const std::string v
Definition: NS.h:84
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.
static InputParameters validParams()
Definition: INSFVFluxBC.C:16
ADReal computeAdvectedQuantity(const Moose::FaceArg &boundary_face, const Moose::StateArg &state)
Computes the advected quantity which is then used on gatherRCData and computeSegregatedContribution.
A class for finite volume fully developed outflow boundary conditions for the momentum equation It ad...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
INSFVMomentumAdvectionOutflowBC(const InputParameters &params)
A parent class for INSFV fully developed flow boundary conditions.
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const