https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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)
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
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
67{
68 const auto boundary_face = singleSidedFaceArg();
69 const auto state = determineState();
70 return _normal *
71 _rc_uo.getVelocity(Moose::FV::InterpMethod::RhieChow,
74 _tid,
75 /*subtract_mesh_velocity=*/true) *
76 computeAdvectedQuantity(boundary_face, state);
77}
78
79void
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
88 if (_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR)
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
112 _rc_uo.addToA((_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? fi.elemPtr() : fi.neighborPtr(),
113 _index,
114 a * (fi.faceArea() * fi.faceCoord()));
115
116 addResidualAndJacobian(strong_resid * (fi.faceArea() * fi.faceCoord()));
117}
DualNumber< Real, DNDerivativeType, true > ADReal
const double v
registerMooseObject("NavierStokesApp", INSFVMomentumAdvectionOutflowBC)
THREAD_ID _tid
SystemBase & _sys
MooseVariableFV< Real > & _var
const FaceInfo * _face_info
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
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 Elem * elemPtr() const
const Elem & neighbor() const
A flux boundary condition that momentum residual objects that add boundary flux terms should inherit ...
Definition INSFVFluxBC.h:20
void addResidualAndJacobian(const ADReal &residual)
Process into either the system residual or Jacobian.
Definition INSFVFluxBC.C:57
static InputParameters validParams()
Definition INSFVFluxBC.C:16
A parent class for INSFV fully developed flow boundary conditions.
static InputParameters validParams()
A class for finite volume fully developed outflow boundary conditions for the momentum equation It ad...
const Moose::Functor< ADReal > *const _w
z-velocity
const unsigned int _dim
the dimension of the simulation
virtual const Moose::FunctorBase< ADReal > & epsFunctor() const
A virtual method that can be overridden in PINSFV classes to return a non-unity porosity.
const Moose::Functor< ADReal > & _rho
The density.
INSFVMomentumAdvectionOutflowBC(const InputParameters &params)
const Moose::Functor< ADReal > & _u
x-velocity
ADReal computeAdvectedQuantity(const Moose::FaceArg &boundary_face, const Moose::StateArg &state)
Computes the advected quantity which is then used on gatherRCData and computeSegregatedContribution.
const Moose::Functor< ADReal > *const _v
y-velocity
void gatherRCData(const FaceInfo &) override
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
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.
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 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.
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