https://mooseframework.inl.gov
WCNSFVMomentumFluxBC.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 "WCNSFVMomentumFluxBC.h"
11 #include "INSFVVelocityVariable.h"
12 #include "NS.h"
13 
14 registerMooseObject("NavierStokesApp", WCNSFVMomentumFluxBC);
15 
18 {
20 
22  params.addClassDescription("Flux boundary conditions for momentum advection.");
23 
24  return params;
25 }
26 
29 {
30  if (!dynamic_cast<INSFVVelocityVariable *>(&_var))
31  paramError(
32  "variable",
33  "The variable argument to WCNSFVMomentumFluxBC must be of type INSFVVelocityVariable");
34 
35  // Need enough information to compute the mass flux
36  if (_mdot_pp && !_area_pp)
37  mooseError("The inlet area should be provided along with the mass flow rate");
38  if (!_mdot_pp && !_velocity_pp)
39  mooseError("Velocity should be provided if the mass flow rate is not");
40 }
41 
42 ADReal
44 {
45  const auto state = determineState();
46 
47  if (!isInflow())
48  {
49  const auto fa = singleSidedFaceArg();
50  const auto vel_vec = varVelocity(state);
51  return vel_vec * _normal * _rho(fa, state) * vel_vec(_index);
52  }
53 
54  const Point incoming_vector =
56  ADReal a = 1;
57  if (_velocity_pp)
58  a = 1.0 / std::abs(incoming_vector * _normal);
59  return -_scaling_factor * a * inflowMassFlux(state) * inflowSpeed(state) *
60  incoming_vector(_index);
61 }
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
const bool _direction_specified_by_user
Flag to store if the flow direction is specified by the user.
const FaceInfo * _face_info
const Moose::Functor< ADReal > & _rho
Fluid density functor.
ADRealVectorValue varVelocity(const Moose::StateArg &state) const
returns the velocity vector (vel_x, vel_y, vel_z)
WCNSFVMomentumFluxBC(const InputParameters &params)
Moose::StateArg determineState() const
const Point _direction
The direction in which the flow is entering/leaving the domain.
const unsigned int _index
index x|y|z
ADReal inflowMassFlux(const Moose::StateArg &state) const
computes the inflow massflux
Base class for weakly compressible flux boundary conditions.
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
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", WCNSFVMomentumFluxBC)
ADReal inflowSpeed(const Moose::StateArg &state) const
computes the inflow speed
static InputParameters validParams()
static InputParameters validParams()
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
ADRealVectorValue _normal
const Point & normal() const
void paramError(const std::string &param, Args... args) const
All objects that contribute to pressure-based (e.g.
Flux boundary conditions for the weakly compressible momentum equation.
virtual bool isInflow() const
true if a boundary is an inflow boundary, false if outflow
const Real _scaling_factor
Scaling factor.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
ADReal computeQpResidual() override