https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12#include "NS.h"
13
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))
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
44{
45 using std::abs;
46
47 const auto state = determineState();
48
49 if (!isInflow())
50 {
51 const auto fa = singleSidedFaceArg();
52 const auto vel_vec = varVelocity(state);
53 return vel_vec * _normal * _rho(fa, state) * vel_vec(_index);
54 }
55
56 const Point incoming_vector =
58 ADReal a = 1;
59 if (_velocity_pp)
60 a = 1.0 / abs(incoming_vector * _normal);
61 return -_scaling_factor * a * inflowMassFlux(state) * inflowSpeed(state) *
62 incoming_vector(_index);
63}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", WCNSFVMomentumFluxBC)
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
const Point & normal() const
All objects that contribute to pressure-based (e.g.
const unsigned int _index
index x|y|z
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
Moose::StateArg determineState() const
Base class for weakly compressible flux boundary conditions.
const Moose::Functor< ADReal > & _rho
Fluid density functor.
const bool _direction_specified_by_user
Flag to store if the flow direction is specified by the user.
ADReal inflowMassFlux(const Moose::StateArg &state) const
computes the inflow massflux
static InputParameters validParams()
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
const Real _scaling_factor
Scaling factor.
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
virtual bool isInflow() const
true if a boundary is an inflow boundary, false if outflow
ADReal inflowSpeed(const Moose::StateArg &state) const
computes the inflow speed
const Point _direction
The direction in which the flow is entering/leaving the domain.
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
ADRealVectorValue varVelocity(const Moose::StateArg &state) const
returns the velocity vector (vel_x, vel_y, vel_z)
Flux boundary conditions for the weakly compressible momentum equation.
ADReal computeQpResidual() override
static InputParameters validParams()
WCNSFVMomentumFluxBC(const InputParameters &params)